dhruv2842 commited on
Commit
57d31f8
Β·
verified Β·
1 Parent(s): 47b3177

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +30 -26
main.py CHANGED
@@ -1,26 +1,30 @@
1
- from fastapi import FastAPI
2
- from fastapi.middleware.cors import CORSMiddleware
3
- from core.database import engine
4
- from core.models.appointment import Appointment
5
- from core.models.user import User
6
- from routes import appointments, users
7
-
8
- # Create FastAPI app first
9
- app = FastAPI()
10
-
11
- # βœ… Enable CORS BEFORE including any routers
12
- app.add_middleware(
13
- CORSMiddleware,
14
- allow_origins=["http://localhost:3000"], # React frontend
15
- allow_credentials=True,
16
- allow_methods=["*"],
17
- allow_headers=["*"],
18
- )
19
-
20
- # Create tables
21
- Appointment.__table__.create(bind=engine, checkfirst=True)
22
- User.__table__.create(bind=engine, checkfirst=True)
23
-
24
- # Register routers
25
- app.include_router(appointments.router)
26
- app.include_router(users.router)
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from fastapi.middleware.cors import CORSMiddleware
3
+ from core.database import engine
4
+ from core.models.appointment import Appointment
5
+ from core.models.user import User
6
+ from routes import appointments, users
7
+
8
+ # Create FastAPI app first
9
+ app = FastAPI()
10
+
11
+ @app.get("/")
12
+ def health_check():
13
+ return {"message": "πŸš€ API is up and running!"}
14
+
15
+ # βœ… Enable CORS BEFORE including any routers
16
+ app.add_middleware(
17
+ CORSMiddleware,
18
+ allow_origins=["http://localhost:3000"], # React frontend
19
+ allow_credentials=True,
20
+ allow_methods=["*"],
21
+ allow_headers=["*"],
22
+ )
23
+
24
+ # Create tables
25
+ Appointment.__table__.create(bind=engine, checkfirst=True)
26
+ User.__table__.create(bind=engine, checkfirst=True)
27
+
28
+ # Register routers
29
+ app.include_router(appointments.router)
30
+ app.include_router(users.router)