sanic/examples/add_task_sanic.py
Adam Hopkins 55c36e0240
Fix examples to work as expected (#2305)
* Fix examples to work as expected

* Clean up examples

* Update worker test

* Merge in from main and cleanup example
2021-11-23 23:00:25 +02:00

20 lines
340 B
Python

# -*- coding: utf-8 -*-
import asyncio
from sanic import Sanic
app = Sanic(__name__)
async def notify_server_started_after_five_seconds():
await asyncio.sleep(5)
print("Server successfully started!")
app.add_task(notify_server_started_after_five_seconds())
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)