-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.py
More file actions
50 lines (38 loc) · 1.17 KB
/
Copy pathmain.py
File metadata and controls
50 lines (38 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
"""
LegalMind Backend Entry Point
Run with: python main.py
"""
import uvicorn
from dotenv import load_dotenv
import os
from pathlib import Path
# Get the backend directory
backend_dir = Path(__file__).parent
# Load environment variables from .env.local first, then .env
load_dotenv(backend_dir / ".env.local")
load_dotenv(backend_dir / ".env")
# Expose ASGI app for Cloud Run buildpacks (expects main:app)
from api.app_new import app as app
def main():
"""Run the LegalMind API server."""
from config.settings import get_settings
settings = get_settings()
# Cloud Run sets PORT env var, default to 8000 for local dev
port = int(os.environ.get("PORT", 8000))
print("=" * 60)
print("LegalMind API Server")
print("=" * 60)
print(f"Project: {settings.google_cloud_project}")
print(f"Debug Mode: {settings.debug}")
print(f"Port: {port}")
print(f"API Docs: http://localhost:{port}/docs")
print("=" * 60)
uvicorn.run(
"api.app_new:app",
host="0.0.0.0",
port=port,
reload=settings.debug,
log_level="info" if settings.debug else "warning",
)
if __name__ == "__main__":
main()