@denis
To load an index.html file in FastAPI, you can use FastAPI's StaticFiles class to serve static files. Here's how you can do it:
1 2 |
from fastapi import FastAPI from fastapi.staticfiles import StaticFiles |
1 2 3 |
app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
|
1 2 3 |
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="127.0.0.1", port=8000)
|
Now, you can access your index.html file by navigating to http://localhost:8000/static/index.html in your web browser.