AhmadYarAI commited on
Commit
cb8dc8e
·
1 Parent(s): 2f7bf0f

Done the configuration

Browse files
Files changed (2) hide show
  1. __init__.py +0 -0
  2. main.py +10 -9
__init__.py ADDED
File without changes
main.py CHANGED
@@ -3,27 +3,28 @@ from pathlib import Path
3
  from fastapi import FastAPI
4
  from fastapi.staticfiles import StaticFiles
5
  from fastapi.responses import FileResponse
6
- from core.database import engine, Base
7
- from api.invoices import router as invoice_router
 
 
8
 
9
  # Create tables in Neon
10
  Base.metadata.create_all(bind=engine)
11
 
12
  app = FastAPI(title="SmiloCAD Invoice API")
13
 
14
- # Always resolve static paths relative to this file (works regardless of CWD)
15
  BASE_DIR = Path(__file__).resolve().parent
 
 
16
  app.mount("/js", StaticFiles(directory=BASE_DIR / "frontend" / "js"), name="js")
17
  app.mount("/css", StaticFiles(directory=BASE_DIR / "frontend" / "css"), name="css")
18
  app.mount("/img", StaticFiles(directory=BASE_DIR / "frontend" / "img"), name="img")
19
 
20
- # 1. Route to serve the index.html
21
  @app.get("/")
22
  async def serve_index():
23
  return FileResponse(BASE_DIR / "frontend" / "index.html")
24
 
25
- # 2. Mount the CSS and JS folders so the HTML can find them
26
- # This matches your folder names: frontend/css and frontend/js
27
-
28
- # Include the routes from the api folder
29
- app.include_router(invoice_router)
 
3
  from fastapi import FastAPI
4
  from fastapi.staticfiles import StaticFiles
5
  from fastapi.responses import FileResponse
6
+
7
+ # FIXED IMPORTS: Added 'backend.' prefix so Vercel can find the modules
8
+ from backend.core.database import engine, Base
9
+ from backend.api.invoices import router as invoice_router
10
 
11
  # Create tables in Neon
12
  Base.metadata.create_all(bind=engine)
13
 
14
  app = FastAPI(title="SmiloCAD Invoice API")
15
 
16
+ # Path logic for Vercel
17
  BASE_DIR = Path(__file__).resolve().parent
18
+
19
+ # Mount Static Files (Ensure these folders exist inside backend/frontend/)
20
  app.mount("/js", StaticFiles(directory=BASE_DIR / "frontend" / "js"), name="js")
21
  app.mount("/css", StaticFiles(directory=BASE_DIR / "frontend" / "css"), name="css")
22
  app.mount("/img", StaticFiles(directory=BASE_DIR / "frontend" / "img"), name="img")
23
 
24
+ # Serve the index.html
25
  @app.get("/")
26
  async def serve_index():
27
  return FileResponse(BASE_DIR / "frontend" / "index.html")
28
 
29
+ # Include the routes - the prefix '/api' is handled by vercel.json
30
+ app.include_router(invoice_router)