Spaces:
Sleeping
Sleeping
Eric Dyke commited on
Commit ·
f5a78b9
1
Parent(s): e479ce9
Add HTML landing page at root path with usage instructions and helpful links for API users
Browse files1234567891011121325 unmodified lines394041424344from fastapi import FastAPIfrom pathlib import Pathfrom fastapi.staticfiles import StaticFilesfrom fastapi.responses import FileResponsefrom routers import spaceship, digitsfrom ml.common.model_loader import load_spaceship_models, load_digit_modelimport joblibapp = FastAPI()BASE_DIR = Path(__file__).resolve().parent25 unmodified linesreturn FileResponse(BASE_DIR / "static" / "favicon.ico")@app.get("/health")def health():return {"status": "ok"}123456789101112131425 unmodified lines404142434445464748495051525354555657585960616263646566676869707172from fastapi import FastAPIfrom pathlib import Pathfrom fastapi.staticfiles import StaticFilesfrom fastapi.responses import FileResponse, HTMLResponsefrom routers import spaceship, digitsfrom ml.common.model_loader import load_spaceship_models, load_digit_modelimport joblibapp = FastAPI()BASE_DIR = Path(__file__).resolve().parent25 unmodified linesreturn FileResponse(BASE_DIR / "static" / "favicon.ico")# Landing page at /@app.get("/", response_class=HTMLResponse, include_in_schema=False)async def root():return """<html><head><title>HighFive52 ML API</title></head><body style='font-family: Arial, sans-serif; max-width: 700px; margin: 40px auto;'><h1>Welcome to the HighFive52 ML API</h1><p>This API provides machine learning endpoints for digit recognition and spaceship prediction.</p><h2>How to Use</h2><ul><li>For interactive API documentation and testing, visit: <a href=\"https://highfive52-ml-api.hf.space/docs\">/docs</a></li><li>To use the API programmatically, send requests to: <a href=\"https://highfive52-ml-api.hf.space\">https://highfive52-ml-api.hf.space</a></li></ul><h2>Links</h2><ul><li>Hugging Face Space: <a href=\"https://huggingface.co/spaces/HighFive52/ml-api\">https://huggingface.co/spaces/HighFive52/ml-api</a></li><li>API Docs: <a href=\"https://highfive52-ml-api.hf.space/docs\">/docs</a></li></ul><p>For more information, see the <a href=\"https://github.com/highfive52/ml-api/blob/main/README.md\">documentation</a> or the <a href=\"https://github.com/HighFive52/ml-api\">GitHub repository</a>.</p></body></html>"""@app.get("/health")def health():return {"status": "ok"}
app.py+29-1