upload
This commit is contained in:
14
test.py
14
test.py
@@ -1,5 +1,5 @@
|
||||
from collections.abc import AsyncGenerator
|
||||
from typing import Any
|
||||
from typing import Any, TextIO
|
||||
|
||||
from app import App
|
||||
from app.components.http import HTTPComponent
|
||||
@@ -21,14 +21,7 @@ async def my_context() -> AsyncGenerator[Any, None]:
|
||||
print("Stop!")
|
||||
|
||||
|
||||
# @lifespan.on_startup
|
||||
# async def start() -> None:
|
||||
# print("Start!")
|
||||
|
||||
|
||||
# @lifespan.on_shutdown
|
||||
# async def stop() -> None:
|
||||
# print("Stop!")
|
||||
lifespan.add_managed_context(open("teapot.log", "w"), name="teapot_log")
|
||||
|
||||
|
||||
@http.route("/teapot", get=True, post=True, put=True, delete=True)
|
||||
@@ -45,4 +38,7 @@ async def teapot() -> HTMLResponse:
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
log = lifespan.get_context("teapot_log", TextIO)
|
||||
_ = log.write("teapot\n")
|
||||
log.flush()
|
||||
return HTMLResponse(status=418, content=resp)
|
||||
|
||||
Reference in New Issue
Block a user