atz21's picture
initial app
3e76441
raw
history blame contribute delete
658 Bytes
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse, JSONResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
app = FastAPI()
app.mount("/static", StaticFiles(directory="static"), name="static")
templates = Jinja2Templates(directory="templates")
@app.get("/", response_class=HTMLResponse)
async def home(request: Request):
return templates.TemplateResponse("index.html", {"request": request})
@app.post("/api/process")
async def process_text(data: dict):
text = data.get("text", "")
result = f"Processed: {text.upper()}"
return JSONResponse({"result": result})