2023-01-08 21:49:16 +00:00
|
|
|
from socketify import App
|
|
|
|
import asyncio
|
|
|
|
app = App(lifespan=False)
|
|
|
|
router = app.router()
|
|
|
|
|
|
|
|
@app.on_start
|
|
|
|
async def on_start():
|
|
|
|
print("wait...")
|
|
|
|
await asyncio.sleep(1)
|
|
|
|
print("start!")
|
|
|
|
|
|
|
|
@app.on_shutdown
|
|
|
|
async def on_shutdown():
|
|
|
|
print("wait...")
|
|
|
|
await asyncio.sleep(1)
|
|
|
|
print("shutdown!")
|
2023-01-06 21:20:34 +00:00
|
|
|
|
|
|
|
@router.get("/")
|
2023-01-07 11:47:50 +00:00
|
|
|
def home(res, req, data=None):
|
|
|
|
# print(data)
|
|
|
|
# print("token", req.token)
|
|
|
|
# cart = await req.get_cart()
|
|
|
|
# print("cart", cart)
|
|
|
|
# user = await req.get_user()
|
|
|
|
# print("user", user)
|
|
|
|
# print("token", req.token)
|
|
|
|
res.send({"Hello": "World!"}, headers=(("X-Rate-Limit-Remaining", "10"), (b'Another-Headers', b'Value')))
|
2023-01-06 19:11:19 +00:00
|
|
|
|
2023-01-06 21:20:34 +00:00
|
|
|
|
2023-01-03 21:05:49 +00:00
|
|
|
app.listen(
|
|
|
|
3000,
|
|
|
|
lambda config: print("Listening on port http://localhost:%d now\n" % config.port),
|
|
|
|
)
|
|
|
|
app.run()
|
2023-01-06 19:11:19 +00:00
|
|
|
|