import os
from app import create_app

# 创建 Flask 应用
app = create_app()

# 设置 secret_key
app.secret_key = os.urandom(24)  # 使用随机生成的安全密钥
# 使用 HTTPS
context = ('ssl/cert.crt', 'ssl/cert.key')
#@app.before_request
#def force_https():
#    if not request.is_secure:
#        url = request.url.replace('http://', 'https://', 1)
#       from flask import redirect
#        return redirect(url, code=301)


# 启动服务器
if __name__ == '__main__':
    app.run(host="0.0.0.0", port=5000, debug=True, ssl_context=context)
    # app.run(debug=True)
