Asma-yaseen commited on
Commit
c563727
·
verified ·
1 Parent(s): adb6862

Upload main.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. main.py +55 -0
main.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Evolution Todo API - FastAPI Backend
3
+
4
+ Task: 1.6
5
+ Spec: specs/overview.md
6
+ """
7
+ from dotenv import load_dotenv
8
+ load_dotenv() # Load .env file first
9
+
10
+ from fastapi import FastAPI
11
+ from fastapi.middleware.cors import CORSMiddleware
12
+ from db import create_db_and_tables
13
+ import os
14
+
15
+ # Initialize FastAPI app
16
+ app = FastAPI(
17
+ title="Evolution Todo API",
18
+ version="1.0.0",
19
+ description="RESTful API for Evolution Todo application"
20
+ )
21
+
22
+ # CORS Configuration
23
+ CORS_ORIGINS = os.getenv("CORS_ORIGINS", "http://localhost:3000").split(",")
24
+
25
+ app.add_middleware(
26
+ CORSMiddleware,
27
+ allow_origins=CORS_ORIGINS,
28
+ allow_credentials=True,
29
+ allow_methods=["*"],
30
+ allow_headers=["*"],
31
+ )
32
+
33
+
34
+ @app.on_event("startup")
35
+ def on_startup():
36
+ """Initialize database tables on startup."""
37
+ create_db_and_tables()
38
+
39
+
40
+ @app.get("/")
41
+ def root():
42
+ """Root endpoint - API status check."""
43
+ return {
44
+ "message": "Evolution Todo API",
45
+ "status": "running",
46
+ "version": "1.0.0"
47
+ }
48
+
49
+
50
+ # Import and include routers
51
+ from routes.tasks import router as tasks_router
52
+ from routes.auth import router as auth_router
53
+
54
+ app.include_router(tasks_router)
55
+ app.include_router(auth_router)