Basic fastapi setup

This commit is contained in:
Marty Oehme 2025-06-05 15:01:39 +02:00
commit 68ef1de2e4
Signed by: Marty
GPG key ID: 4E535BC19C61886E
6 changed files with 712 additions and 0 deletions

56
prophet/app.py Normal file
View file

@ -0,0 +1,56 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
origins = [
"http://localhost",
"http://localhost:8080",
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/test")
def read_root():
response = {
"data": [
{
"id": 1,
"name": "Chocolate",
"price": "4.50",
},
{
"id": 2,
"name": "Sorvete",
"price": "2.42",
},
{
"id": 3,
"name": "Refrigerante",
"price": "4.90",
},
{
"id": 4,
"name": "X-salada",
"price": "7.99",
},
]
}
return response
def start() -> None:
from uvicorn import run
run("prophet.app:app", reload=True)
if __name__ == "__main__":
start()