上传文件至 core
This commit is contained in:
29
core/WebApp.py
Normal file
29
core/WebApp.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import flask
|
||||
|
||||
app = flask.Flask(__name__, template_folder='../webfile', static_folder='../webfile/static')
|
||||
|
||||
@app.errorhandler(500)
|
||||
def internal_server_error(error):
|
||||
# 返回500错误的HTML页面
|
||||
return flask.render_template("/error/500.html",error=error,static_url_path='/static')
|
||||
|
||||
@app.errorhandler(404)
|
||||
def not_found(error):
|
||||
# 返回404错误的HTML页面
|
||||
return flask.render_template("/error/404.html",error=error,static_url_path='/static'),404
|
||||
|
||||
@app.errorhandler(403)
|
||||
def forbidden(error):
|
||||
# 返回403错误的HTML页面
|
||||
return flask.render_template("/error/403.html",error=error,static_url_path='/static'),403
|
||||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return flask.render_template('index.html')
|
||||
|
||||
def AppStart(host: str, port: int):
|
||||
"""启动Flask应用"""
|
||||
app.run(host=host, port=port, debug=True, use_reloader=False)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host="127.0.0.1", port=5000, debug=True)
|
Reference in New Issue
Block a user