标签:turn 开发 text with tle span start exist imp
from bottle import error @error(404) def error404(error): return ‘Nothing here, sorry‘
上述代码,是对404的定义,这里注意,有一个HTTPError,
HTTPError
uses a predefined HTML template to build the body of the response. Instead of using HTTPError
you can use response
with the appropriate status code and body.
import json from bottle import run, route, response @route(‘/text‘) def get_text(): response.status = 400 return ‘Object already exists with that name‘ @route(‘/json‘) def get_json(): response.status = 400 response.content_type = ‘application/json‘ return json.dumps({‘error‘: ‘Object already exists with that name‘}) # Start bottle server. run(host=‘0.0.0.0‘, port=8070, debug=True)
标签:turn 开发 text with tle span start exist imp
原文地址:http://www.cnblogs.com/aomi/p/7048125.html