from flask import Flask, render_template, request, redirect, url_for, abort
import xlsxwriter
import testexecute
import json
import datetime
from requests.models import Response
#from flask_bcrypt import Bcrypt
from flask_sqlalchemy import SQLAlchemy
from config import BaseConfig
app = Flask(__name__)
app.config.from_object(BaseConfig)
#bcryptt = Bcrypt(app)
db = SQLAlchemy(app)
import constants
@app.route('/')
def index():
return render_template('Index.html')
@app.route('/error')
def error():
print("error")
return render_template('errorPage.html')
@app.errorhandler(500)
def internal_server_error(e):
print("internal_server_error")
return render_template('500.html')
@app.errorhandler(400)
def page_not_found(e):
print("page_not_found")
return render_template('400.html'), 400
@app.route('/testExecution', methods=['POST'])
def invoke_testExecution():
try:
testexecute.execute(request)
return "Test Started"
except:
print("Jenkins Exception")
return "Test Aborted"
#return redirect(url_for('error'))
if __name__ == '__main__':
app.run(debug=False, host='0.0.0.0')
我在templates目录下有Index.html,errorPage.html,500.html文件。 'index.html'变好了。当我路由到那些消息时,会显示消息“error”和“internal_server_error”,但不会呈现模板“500.html”和“errorPage.html”。如果状态为500,则在浏览器控制台上打印500.html的内容,但不会进行重定向!请帮忙!
500.html
:
<html>
<h2>Server error</h2>
</html>
errorPage.html
:
<!doctype html>
<html ng-app="horizonApp">
We are sorry to inform you that some error occured!!
Please <a href="#!/login" class="btn btn-link">Login</a> again!!
</html>