testspaces / app.py
dauduchieu's picture
api
96337e7 verified
Raw
History Blame Contribute Delete
474 Bytes
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Chấp nhận tất cả (có thể đổi thành frontend của bạn)
allow_credentials=True,
allow_methods=["*"], # Cho phép tất cả phương thức (GET, POST,...)
allow_headers=["*"], # Cho phép tất cả headers
)
@app.get("/api")
def greet_json():
return {"Hello": "World!1"}