upload
This commit is contained in:
27
test.py
27
test.py
@@ -1,15 +1,36 @@
|
||||
from collections.abc import AsyncGenerator
|
||||
from typing import Any
|
||||
|
||||
from app import App
|
||||
from app.components.http import HTTPComponent
|
||||
|
||||
# from app.components.lifespan import LifespanComponent
|
||||
from app.components.lifespan import LifespanComponent
|
||||
from app.subroutines.http import HTMLResponse
|
||||
|
||||
app = App()
|
||||
|
||||
# lifespan = app.use_component(LifespanComponent())
|
||||
lifespan = app.use_component(LifespanComponent())
|
||||
http = app.use_component(HTTPComponent())
|
||||
|
||||
|
||||
@lifespan.on_context
|
||||
async def my_context() -> AsyncGenerator[Any, None]:
|
||||
try:
|
||||
print("Start!")
|
||||
yield
|
||||
finally:
|
||||
print("Stop!")
|
||||
|
||||
|
||||
# @lifespan.on_startup
|
||||
# async def start() -> None:
|
||||
# print("Start!")
|
||||
|
||||
|
||||
# @lifespan.on_shutdown
|
||||
# async def stop() -> None:
|
||||
# print("Stop!")
|
||||
|
||||
|
||||
@http.route("/teapot", get=True, post=True, put=True, delete=True)
|
||||
async def teapot() -> HTMLResponse:
|
||||
resp = """
|
||||
|
||||
Reference in New Issue
Block a user