Last active
December 30, 2021 19:04
-
-
Save kaustubhgupta/fdb3a3bdf3ae786c4594951944759af7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastapi import FastAPI, Request | |
from fastapi.templating import Jinja2Templates | |
from fastapi.responses import HTMLResponse | |
import uvicorn | |
app = FastAPI() | |
templates = Jinja2Templates(directory="demo") | |
@app.get('/', response_class=HTMLResponse) | |
def index(request: Request): | |
return templates.TemplateResponse("demo.html", {"request": request, "title": "Kaustubh Demo", "body_content": "This is the demo for using FastAPI with Jinja templates"}) | |
if __name__ == "__main__": | |
uvicorn.run("demo2:app", host='127.0.0.1', port=8000, reload=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment