首页 > 解决方案 > 如何处理flask-classful中的http错误?

问题描述

我正在使用flask_classful,毫无疑问它是一个了不起的扩展。现在我想处理 404、500 等 http 错误。我不知道如何在flask-classful 中做到这一点。请帮我 !

from flask import Flask, render_template
from flask_classful import FlaskView, route

app = Flask(__name__)


friends = ({'1st' : 'honey', '2nd' : 'ayush'})

class HomeView(FlaskView):
    route_base  = '/'

    def home(self):
        return render_template('global.html', title='Flask Claasful')

    @route('/new/')
    def new_func(self):
        return render_template('global.html', title='Flask Classy')

    @route('/friends/')
    def friends(self):
        return friends



HomeView.register(app)


if __name__ == '__main__':
    app.run()

标签: pythonpython-3.xflask

解决方案


推荐阅读