usr bin env python coding utf-8 from __future__ import division unicod

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
# coding: utf-8
from __future__ import division, unicode_literals
from flask import Flask, jsonify, render_template, request
app = Flask(__name__)
@app.route('/ok')
def ff():
return "Always ok"
@app.route('/')
def index():
raise UnicodeError
return "ok"
@app.after_request
def per_request_callbacks(response):
print "I am after_request function!", response
return response
@app.teardown_request
def teardown_request(exception=None):
import ipdb; ipdb.set_trace()
print "I am teardown_request request function!", exception
if __name__ == '__main__':
app.run()