Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 745 Bytes
b5bf16b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
from starlette.applications import Starlette
from starlette.exceptions import HTTPException
from starlette.responses import FileResponse, JSONResponse, HTMLResponse
from starlette.requests import Request
from starlette.routing import Route
async def homepage(_):
return FileResponse("static/index.html")
async def healthz(_):
return JSONResponse({"success": True})
async def convert(req: Request):
url = req.query_params.get("url")
if not url:
raise HTTPException(400, "Param url is missing")
print(url)
return HTMLResponse("<strong>FOO</strong>")
app = Starlette(
debug=True,
routes=[
Route("/", homepage),
Route("/healthz", healthz),
Route("/convert", convert),
],
)
|