second commit
This commit is contained in:
16
main.py
16
main.py
@ -18,7 +18,7 @@ from rich.table import Table
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Annotated, Optional
|
||||
from fastapi import FastAPI, HTTPException, Depends, Request
|
||||
from fastapi import FastAPI, HTTPException, Depends, Request, Form
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from pydantic import BaseModel
|
||||
@ -27,7 +27,9 @@ import uvicorn
|
||||
|
||||
# Initialize FastAPI app
|
||||
app = FastAPI(
|
||||
title="FastAPI Template", description="A simple FastAPI template with basic CRUD operations", version="1.0.0"
|
||||
title="FastAPI Template",
|
||||
description="A simple FastAPI template with basic CRUD operations",
|
||||
version="1.0.0",
|
||||
)
|
||||
|
||||
app.mount("/static", StaticFiles(directory="static"), name="static")
|
||||
@ -39,7 +41,9 @@ templates = Jinja2Templates(directory="templates")
|
||||
# Main Landing Page
|
||||
@app.get("/")
|
||||
async def main(request: Request):
|
||||
return templates.TemplateResponse("pages/index.html", {"request": request, "title": "Home Page"})
|
||||
return templates.TemplateResponse(
|
||||
"pages/index.html", {"request": request, "title": "Home Page"}
|
||||
)
|
||||
|
||||
|
||||
# Health check endpoint
|
||||
@ -48,5 +52,11 @@ async def health_check():
|
||||
return {"status": "healthy"}
|
||||
|
||||
|
||||
@app.post("/search")
|
||||
async def search(category: str = Form(...), query: str = Form(...)):
|
||||
print(category)
|
||||
print(query)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)
|
||||
|
Reference in New Issue
Block a user