|
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") |
|
|
|
|
|
|
|
class DatasetForm(BaseModel): |
|
dataset_name: str |
|
|
|
|
|
|
|
@app.get("/", response_class=HTMLResponse) |
|
async def read_form(request: Request): |
|
|
|
return templates.TemplateResponse("form.html", {"request": request}) |
|
|
|
|
|
@app.post("/submit_form") |
|
async def form_post(form_data: DatasetForm): |
|
|
|
print(form_data.dict()) |
|
return {"message": "Form data received!", "received_data": form_data.dict()} |
|
|
|
|
|
|
|
|