Spaces:
Sleeping
Sleeping
File size: 1,763 Bytes
90537f3 0702b8b f0fe332 0702b8b f0fe332 0702b8b f0fe332 0702b8b 90537f3 |
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 51 52 53 54 55 56 57 58 59 |
#!/usr/bin/env python3
"""
Tabble-v3 Restaurant Management System
Entry point for Hugging Face Spaces deployment
"""
import uvicorn
import os
import sys
from pathlib import Path
# Add the app directory to the Python path
app_dir = Path(__file__).parent / "app"
sys.path.insert(0, str(app_dir))
def main():
"""Main entry point for the application"""
# Create static directories if they don't exist
os.makedirs("app/static/images/dishes", exist_ok=True)
os.makedirs("templates", exist_ok=True)
# Ensure database file is in the correct location for Docker
source_db = "Tabble.db"
target_db = "Tabble.db" # Same location in Docker
try:
if os.path.exists(source_db):
print(f"✅ Database found at {source_db}")
else:
print(f"⚠️ Database not found at {source_db}, will create new one")
except Exception as e:
print(f"⚠️ Database setup warning: {e}")
# Set environment variables for Hugging Face Spaces
os.environ.setdefault("HUGGINGFACE_SPACES", "1")
# Get port from environment (Hugging Face Spaces uses 7860)
port = int(os.environ.get("PORT", 7860))
host = os.environ.get("HOST", "0.0.0.0")
print(f"🚀 Starting Tabble-v3 Restaurant Management System")
print(f"📡 Server: http://{host}:{port}")
print(f"📖 API Documentation: http://{host}:{port}/docs")
print(f"🏥 Health Check: http://{host}:{port}/health")
print("=" * 60)
# Start the FastAPI application
uvicorn.run(
"app.main:app",
host=host,
port=port,
reload=False, # Disable reload in production
log_level="info",
access_log=True
)
if __name__ == "__main__":
main() |