Эх сурвалжийг харах

更新 'api/run.py'

网页接口更新和网页更新介绍内容数据库
qw 3 сар өмнө
parent
commit
2d3058fdc8
1 өөрчлөгдсөн 15 нэмэгдсэн , 1 устгасан
  1. 15 1
      api/run.py

+ 15 - 1
api/run.py

@@ -1,8 +1,22 @@
+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(debug=True)
+    app.run(host="0.0.0.0", port=5000, debug=True, ssl_context=context)
+    # app.run(debug=True)