| import os | |
| from App import create_app # Ensure your folder name is 'App' or 'app' | |
| # Get the directory where run.py is located | |
| basedir = os.path.abspath(os.path.dirname(__file__)) | |
| # Create the application instance | |
| app = create_app() | |
| # Override paths to be relative to run.py location | |
| # NOTE: Check if your folders are 'Static' or 'static' (Linux is case-sensitive!) | |
| app.static_folder = os.path.join(basedir, 'Static') | |
| app.template_folder = os.path.join(basedir, 'Templates') | |
| def debug_paths(): | |
| return f""" | |
| <div style="font-family: sans-serif; padding: 20px;"> | |
| <h2>π Path Debugger</h2> | |
| <p><strong>Base Directory:</strong> {basedir}</p> | |
| <p><strong>Static Folder:</strong> {app.static_folder} ({'β Found' if os.path.exists(app.static_folder) else 'β Not Found'})</p> | |
| <p><strong>Template Folder:</strong> {app.template_folder} ({'β Found' if os.path.exists(app.template_folder) else 'β Not Found'})</p> | |
| <hr> | |
| <p><a href="/">Go to Homepage</a></p> | |
| </div> | |
| """ | |
| if __name__ == '__main__': | |
| # Default port for Hugging Face Spaces is 7860 | |
| port = int(os.environ.get("PORT", 7860)) | |
| # In production, debug should be False | |
| app.run(host="0.0.0.0", port=port, debug=True) |