atlas-map / app.py
Richard Guo
base app
1bacad4
raw
history blame
773 Bytes
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
from typing import Optional
from pydantic import BaseModel
app = FastAPI()
templates = Jinja2Templates(directory="templates")
# Create a Pydantic model for the form data
class DatasetForm(BaseModel):
dataset_name: str
@app.get("/", response_class=HTMLResponse)
async def read_form(request: Request):
# Render the form.html template
return templates.TemplateResponse("form.html", {"request": request})
@app.post("/submit_form")
async def form_post(form_data: DatasetForm):
# Do something with form_data
print(form_data.dict())
return {"message": "Form data received!", "received_data": form_data.dict()}