Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
-
from
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
app.include_router(tao_baogia.router)
|
| 7 |
-
app.include_router(phe_duyet.router)
|
| 8 |
|
| 9 |
-
|
| 10 |
-
def test():
|
| 11 |
-
return {"ok": True}
|
| 12 |
-
|
| 13 |
-
@app.get("/")
|
| 14 |
-
def root():
|
| 15 |
-
return {"message": "✅ Backend is running"}
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
from fastapi import FastAPI
|
| 3 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 4 |
|
| 5 |
+
# Import các router (sẽ tạo sau)
|
| 6 |
+
from routes import pyc_router, baogia_router, doanhthu_router
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
app = FastAPI(title="Backend Quản lý Phòng Thí Nghiệm")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
# Cho phép frontend (HTML, JS) truy cập
|
| 11 |
+
app.add_middleware(
|
| 12 |
+
CORSMiddleware,
|
| 13 |
+
allow_origins=["*"],
|
| 14 |
+
allow_credentials=True,
|
| 15 |
+
allow_methods=["*"],
|
| 16 |
+
allow_headers=["*"],
|
| 17 |
+
)
|
| 18 |
|
| 19 |
+
# Gắn các router
|
| 20 |
+
app.include_router(pyc_router, prefix="/pyc")
|
| 21 |
+
app.include_router(baogia_router, prefix="/baogia")
|
| 22 |
+
app.include_router(doanhthu_router, prefix="/doanhthu")
|
| 23 |
|
| 24 |
+
@app.get("/")
|
| 25 |
+
def root():
|
| 26 |
+
return {"message": "✅ Backend đang chạy!"}
|