import sys
import os
# Add your project directory to the sys.path
sys.path.insert(0, os.path.dirname(__file__))
from app import app as application
if __name__ == "__main__":
application.run()
تحديث app.py لدعم MySQL:
إضافة إلى app.py
# MySQL Database Configuration for cPanel
database_url = os.environ.get("DATABASE_URL")
if not database_url:
# Default MySQL connection for cPanel
database_url = "mysql+pymysql://username:password@localhost/database_name"
# Ensure MySQL format
if database_url.startswith("mysql://"):
database_url = database_url.replace("mysql://", "mysql+pymysql://", 1)
app.config["SQLALCHEMY_DATABASE_URI"] = database_url
app.config["SQLALCHEMY_ENGINE_OPTIONS"] = {
"pool_recycle": 3600,
"pool_pre_ping": True,
"pool_size": 3,
"max_overflow": 2,
"echo": False,
"connect_args": {
"charset": "utf8mb4",
"init_command": "SET sql_mode='STRICT_TRANS_TABLES'",
}
}
نصيحة:
استبدل username، password، database_name بالقيم الصحيحة من قاعدة البيانات التي أنشأتها.