wolf1997 commited on
Commit
7f8640a
·
verified ·
1 Parent(s): fd1247e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -13,8 +13,11 @@ from typing import List
13
  # Import your LangGraph receipt scanner agent
14
  from receipt_gen_agent import receipt_agent
15
 
16
- app = FastAPI(title="Receipt Scanner API")
17
-
 
 
 
18
  # Configure CORS to allow requests from your React app
19
  app.add_middleware(
20
  CORSMiddleware,
@@ -119,7 +122,15 @@ async def process_receipt(request: ImageRequest):
119
  except Exception as e:
120
  print(f"API error: {str(e)}")
121
  raise HTTPException(status_code=500, detail=f"Error processing images: {str(e)}")
122
-
 
 
 
 
 
 
 
 
123
  # Health check endpoint
124
  @app.get("/health")
125
  async def health_check():
 
13
  # Import your LangGraph receipt scanner agent
14
  from receipt_gen_agent import receipt_agent
15
 
16
+ HF_SPACE_URL = os.environ.get("SPACE_URL", "")
17
+ app = FastAPI(
18
+ title="Receipt Scanner API",
19
+ root_path="/" if not HF_SPACE_URL else HF_SPACE_URL
20
+ )
21
  # Configure CORS to allow requests from your React app
22
  app.add_middleware(
23
  CORSMiddleware,
 
122
  except Exception as e:
123
  print(f"API error: {str(e)}")
124
  raise HTTPException(status_code=500, detail=f"Error processing images: {str(e)}")
125
+ @app.get("/")
126
+ async def root():
127
+ return {
128
+ "message": "Receipt Scanner API is running",
129
+ "endpoints": {
130
+ "scan": "/api/scan",
131
+ "health": "/health"
132
+ }
133
+ }
134
  # Health check endpoint
135
  @app.get("/health")
136
  async def health_check():