from flask import request

from app import create_app
import os
# 创建 Flask 应用
app = create_app()

# 使用 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)
