第一次提交
This commit is contained in:
38
run.py
Normal file
38
run.py
Normal file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
应用启动文件
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
# 添加项目根目录到Python路径
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
# 尝试加载.env文件
|
||||
try:
|
||||
from dotenv import load_dotenv
|
||||
if load_dotenv():
|
||||
print("成功加载.env文件")
|
||||
else:
|
||||
print("未找到或无法加载.env文件")
|
||||
except ImportError:
|
||||
print("python-dotenv未安装,跳过.env文件加载")
|
||||
|
||||
from app import create_app
|
||||
|
||||
# 创建应用实例
|
||||
app = create_app()
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 获取配置
|
||||
config_name = os.environ.get('FLASK_CONFIG') or 'production'
|
||||
print(f"Configuration name: {config_name}")
|
||||
|
||||
# 运行应用
|
||||
app.run(
|
||||
host=os.environ.get('HOST', '0.0.0.0'),
|
||||
port=int(os.environ.get('PORT', 5088)),
|
||||
debug=app.config.get('DEBUG', False)
|
||||
)
|
||||
Reference in New Issue
Block a user