2017-08-20 11:11:14 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import asyncio
|
|
|
|
|
|
|
|
from sanic import Sanic
|
|
|
|
|
2021-11-23 23:00:25 +02:00
|
|
|
|
2021-12-24 00:30:27 +02:00
|
|
|
app = Sanic("Example")
|
2017-08-20 11:11:14 +08:00
|
|
|
|
|
|
|
|
|
|
|
async def notify_server_started_after_five_seconds():
|
|
|
|
await asyncio.sleep(5)
|
2021-11-23 23:00:25 +02:00
|
|
|
print("Server successfully started!")
|
|
|
|
|
2017-08-20 11:11:14 +08:00
|
|
|
|
|
|
|
app.add_task(notify_server_started_after_five_seconds())
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
app.run(host="0.0.0.0", port=8000)
|