Seth0330 commited on
Commit
92314c4
·
verified ·
1 Parent(s): 8e1087e

Create backend/app/main.py

Browse files
Files changed (1) hide show
  1. backend/app/main.py +30 -0
backend/app/main.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from fastapi import FastAPI
3
+ from fastapi.middleware.cors import CORSMiddleware
4
+ from .db import Base, engine
5
+
6
+ # Ensure data directory exists (for SQLite file)
7
+ os.makedirs("data", exist_ok=True)
8
+
9
+ # Create tables
10
+ Base.metadata.create_all(bind=engine)
11
+
12
+ app = FastAPI(title="Document Capture Demo – Backend")
13
+
14
+ # Allow CORS from anywhere (fine for a demo Space)
15
+ app.add_middleware(
16
+ CORSMiddleware,
17
+ allow_origins=["*"],
18
+ allow_credentials=True,
19
+ allow_methods=["*"],
20
+ allow_headers=["*"],
21
+ )
22
+
23
+
24
+ @app.get("/ping")
25
+ def ping():
26
+ """
27
+ Simple health check endpoint.
28
+ You can hit this from the browser to confirm backend is running.
29
+ """
30
+ return {"status": "ok", "message": "backend alive"}