簡體   English   中英

閃爍500內部服務器錯誤以使用Python篩選Flask

[英]Flashing 500 Internal Server Error to screen Flask with Python

一個簡單的問題,我希望...開發過程中出現500個內部錯誤,並希望將它們刷新到瀏覽器屏幕上,以便更輕松地處理時間。 用Flask和Python做到這一點的最簡單方法是什么? 謝謝。

在flask jinja模板中編寫custome錯誤頁面,並在屏幕上顯示您要閃爍的方式

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 %}

500表示您的演示中出了點問題。也可能會顯示錯誤消息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM