Spaces:
Sleeping
Sleeping
File size: 2,269 Bytes
90537f3 9d5f319 0702b8b f0fe332 9d5f319 0702b8b f0fe332 0702b8b 9d5f319 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 60 61 62 63 64 65 66 67 68 69 70 71 |
#!/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() |