Spaces:
Paused
Paused
Update main.py
Browse files
main.py
CHANGED
|
@@ -4,11 +4,10 @@ from fastapi import FastAPI, HTTPException
|
|
| 4 |
from fastapi.middleware.cors import CORSMiddleware
|
| 5 |
from fastapi.responses import JSONResponse
|
| 6 |
from app.core.config import settings
|
| 7 |
-
from app.
|
| 8 |
-
from .
|
| 9 |
import logging
|
| 10 |
import sys
|
| 11 |
-
from fastapi.responses import PlainTextResponse
|
| 12 |
|
| 13 |
# Configure Windows-specific event loop policy
|
| 14 |
if platform.system() == 'Windows':
|
|
@@ -37,23 +36,19 @@ app.add_middleware(
|
|
| 37 |
)
|
| 38 |
|
| 39 |
# Include API router
|
| 40 |
-
app.include_router(
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
| 43 |
|
| 44 |
@app.exception_handler(HTTPException)
|
| 45 |
async def http_exception_handler(request, exc):
|
| 46 |
-
logger.error(f"HTTP Exception at {request.url}: {exc.detail}")
|
| 47 |
return JSONResponse(
|
| 48 |
status_code=exc.status_code,
|
| 49 |
content={"detail": exc.detail}
|
| 50 |
)
|
| 51 |
|
| 52 |
-
@app.exception_handler(Exception)
|
| 53 |
-
async def unhandled_exception_handler(request, exc):
|
| 54 |
-
logger.error(f"Unhandled exception at {request.url}: {exc}", exc_info=True)
|
| 55 |
-
return PlainTextResponse("Internal Server Error", status_code=500)
|
| 56 |
-
|
| 57 |
@app.get("/")
|
| 58 |
async def root():
|
| 59 |
return {"message": "POS Backend API", "version": "1.0.0"}
|
|
@@ -71,6 +66,5 @@ async def startup_event():
|
|
| 71 |
if __name__ == "__main__":
|
| 72 |
import uvicorn
|
| 73 |
logger.info("Starting application with Windows-compatible event loop...")
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
|
|
|
| 4 |
from fastapi.middleware.cors import CORSMiddleware
|
| 5 |
from fastapi.responses import JSONResponse
|
| 6 |
from app.core.config import settings
|
| 7 |
+
from app.db.database import init_db # Direct import from database.py
|
| 8 |
+
from app.api.v1.endpoints import auth, menu, orders, payments, reports
|
| 9 |
import logging
|
| 10 |
import sys
|
|
|
|
| 11 |
|
| 12 |
# Configure Windows-specific event loop policy
|
| 13 |
if platform.system() == 'Windows':
|
|
|
|
| 36 |
)
|
| 37 |
|
| 38 |
# Include API router
|
| 39 |
+
app.include_router(auth.router, prefix=f"{settings.API_V1_STR}/auth")
|
| 40 |
+
app.include_router(menu.router, prefix=f"{settings.API_V1_STR}/menu")
|
| 41 |
+
app.include_router(orders.router, prefix=f"{settings.API_V1_STR}/orders")
|
| 42 |
+
app.include_router(payments.router, prefix=f"{settings.API_V1_STR}/payments")
|
| 43 |
+
app.include_router(reports.router, prefix=f"{settings.API_V1_STR}/reports")
|
| 44 |
|
| 45 |
@app.exception_handler(HTTPException)
|
| 46 |
async def http_exception_handler(request, exc):
|
|
|
|
| 47 |
return JSONResponse(
|
| 48 |
status_code=exc.status_code,
|
| 49 |
content={"detail": exc.detail}
|
| 50 |
)
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
@app.get("/")
|
| 53 |
async def root():
|
| 54 |
return {"message": "POS Backend API", "version": "1.0.0"}
|
|
|
|
| 66 |
if __name__ == "__main__":
|
| 67 |
import uvicorn
|
| 68 |
logger.info("Starting application with Windows-compatible event loop...")
|
| 69 |
+
|
| 70 |
+
uvicorn.run("main:app", host="0.0.0.0", port=7860, reload=True, log_level="debug")
|
|
|