File size: 496 Bytes
1809ff7 d057bd6 1809ff7 d057bd6 1809ff7 d057bd6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
from pydantic import BaseModel
class Item(BaseModel):
name: str
price: float
app = FastAPI()
@app.get("/")
def home():
html_content = open('index.html').read()
return HTMLResponse(content=html_content, status_code=200)
@app.get("/hello")
def hello():
return {"hello": "world"}
@app.post("/items")
def update_item(item: Item):
return {"item_name": item.name, "twice price": item.price * 2}
|