@app.get("/", response_class=HTMLResponse) async def index(request: Request): print('Request for index page received') return templates.TemplateResponse('index.html', {"request": request}) @app.post('/hello', response_class=HTMLResponse) async def hello(request: Request, name: str = Form(...)): if name: print('Request for hello page received with name=%s' % name) return templates.TemplateResponse('hello.html', {"request": request, 'name':name}) else: print('Request for hello page received with no name or blank name -- redirecting') return RedirectResponse(request.url_for("index"), status_code=status.HTTP_302_FOUND)