python - 如何处理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()
解决方案
推荐阅读
- prolog - findall 的异常行为
- cobol - COBOL 如何实际接受数值?
- javascript - 键入时自动更改焦点
- datetime - jmeter将人类可读的日期转换为纪元
- c# - 使用没有 OrderBy 和过滤器的 First/FirstOrDefault/Last/LastOrDefault 操作,这可能会导致不可预测的结果
- asp.net - ASP.NET 4.8 Azure DevOps YAML 构建错误
- python - aws iam 角色从 CloudFormation 转移到 CDK
- java - Spring JpaRepository 不会删除表中的行
- javascript - 响应式网页:关闭时可见的响应式导航菜单
- r - 为什么 read_csv 的结果比 read.csv 的大?