闪烁500内部服务器错误以使用Python筛选Flask

时间:2017-11-11 07:39:39

标签: python flask

简单的问题我希望...... 我在开发时遇到500个内部错误,并希望将它们闪存到浏览器屏幕以便更容易转换时间。使用带有Python的Flask最简单的方法是什么? 感谢。

2 个答案:

答案 0 :(得分:1)

在flask jinja模板中写下custome custom错误页面并显示你想要在屏幕上闪烁的方式

from flask import render_template

@app.errorhandler(500)
def page_not_found(e):
    return render_template('500.html'), 404

#An example template might be this for your 5000.html, you can write 
#your own through this code:

{% extends "layout.html" %}
{% block title %}Page Not Found{% endblock %}
{% block body %}
  <h1>Page Not Found</h1>
  <p>What you were looking for is just not there.
  <p><a href="{{ url_for('index') }}">go somewhere nice</a>
{% endblock %}

答案 1 :(得分:-1)

500表示您的demo.may中存在错误,也可能出现错误信息