Spaces:
Sleeping
Sleeping
| #!/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) | |
| # Debug: Check current directory and files | |
| print(f"π Current working directory: {os.getcwd()}") | |
| print(f"π Files in current directory: {os.listdir('.')}") | |
| # Check for database file | |
| db_files = [f for f in os.listdir('.') if f.endswith('.db')] | |
| print(f"π Database files found: {db_files}") | |
| # Ensure database file is accessible | |
| source_db = "Tabble.db" | |
| try: | |
| if os.path.exists(source_db): | |
| size = os.path.getsize(source_db) | |
| print(f"β Database found: {source_db} ({size} bytes)") | |
| # Check if file is readable | |
| with open(source_db, 'rb') as f: | |
| f.read(16) # Try to read first 16 bytes | |
| print(f"β Database file is readable") | |
| else: | |
| print(f"β οΈ Database not found at {source_db}, will create new one") | |
| except Exception as e: | |
| print(f"β οΈ Database file check error: {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() |