newBlog / run.py
mistpe's picture
Update run.py
50d08ad verified
raw
history blame contribute delete
562 Bytes
from app import create_app, db
from app.models import Article, Image
import os
from dotenv import load_dotenv
# 加载环境变量
load_dotenv()
# 创建应用实例
app = create_app()
# 创建命令行上下文
@app.shell_context_processor
def make_shell_context():
return {
'db': db,
'Article': Article,
'Image': Image
}
if __name__ == '__main__':
# 在开发环境中启动应用
app.run(
host='0.0.0.0',
port=int(os.getenv('PORT', 7860)),
debug=os.getenv('FLASK_ENV') == 'development'
)