nbconvert / app.py
julien-c's picture
julien-c HF staff
scaffolding
b5bf16b verified
raw
history blame
745 Bytes
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),
],
)