from fastapi import FastAPI | |
from fastapi.responses import HTMLResponse | |
from pydantic import BaseModel | |
class Item(BaseModel): | |
name: str | |
price: float | |
app = FastAPI() | |
def home(): | |
html_content = open('index.html').read() | |
return HTMLResponse(content=html_content, status_code=200) | |
def hello(): | |
return {"hello": "world"} | |
def update_item(item: Item): | |
return {"item_name": item.name, "twice price": item.price * 2} | |