Spaces:
Running
Running
#!/usr/bin/env python3 | |
""" | |
Tokenizer Pro - HuggingFace Space Launcher | |
This file serves as the entry point for HuggingFace Spaces, which expects app.py. | |
It imports and runs the restructured Flask application from the app/ package. | |
""" | |
import os | |
from app import create_app | |
from config import Config, DevelopmentConfig, ProductionConfig | |
def get_config_class(): | |
"""Determine which configuration class to use based on environment.""" | |
env = os.getenv('FLASK_ENV', 'development').lower() | |
if env == 'production': | |
return ProductionConfig | |
elif env == 'development': | |
return DevelopmentConfig | |
else: | |
return Config | |
# Create the Flask application using the app factory | |
app = create_app(get_config_class()) | |
if __name__ == "__main__": | |
# Get configuration from environment variables | |
host = os.getenv('HOST', '0.0.0.0') | |
port = int(os.getenv('PORT', 7860)) | |
debug = os.getenv('DEBUG', 'False').lower() in ('true', '1', 'yes') | |
app.run(host=host, port=port, debug=debug) |