本文整理汇总了Python中flask.ext.api.FlaskAPI.debug方法的典型用法代码示例。如果您正苦于以下问题:Python FlaskAPI.debug方法的具体用法?Python FlaskAPI.debug怎么用?Python FlaskAPI.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask.ext.api.FlaskAPI
的用法示例。
在下文中一共展示了FlaskAPI.debug方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from flask.ext.api import FlaskAPI [as 别名]
# 或者: from flask.ext.api.FlaskAPI import debug [as 别名]
return {"message": "Success!", "success": 1}
# note that backup.csv has fields: [id,title,author,date,content].
@app.route("/update")
@token_auth
def update():
title = request.data.get("title")
author = request.data.get("author")
date = request.data.get("date")
url = request.data.get("url")
content = request.data.get("content")
if content and len(content) > 100:
with open("backup.csv") as source:
reader = csv.DictReader(source.read().splitlines())
# return "number of row: " + str(len(list(reader))) # return the number of rows inside backup.csv, used as next index.
rowid = str(len(list(reader)))
newrow = map(toUTF, [rowid, title, author, date, url, content])
with open("backup.csv", "a") as target:
writer = csv.writer(target)
writer.writerow(newrow)
# return newrow # instead of returning that new post(look redundant), show a successful meg just be fine!
return "Your post: <" + title + "> has been succesfully uploaded to databased!!!"
else:
return "Just a reminder that it's successfully updated, while it won't modify the database for now."
if __name__ == "__main__":
app.debug = True
app.run()
示例2: handle_invalid_graph_error
# 需要导入模块: from flask.ext.api import FlaskAPI [as 别名]
# 或者: from flask.ext.api.FlaskAPI import debug [as 别名]
return error_details, status.HTTP_400_BAD_REQUEST
@app.errorhandler(GraphQLError)
def handle_invalid_graph_error(graphql_error):
error_message = format_error(graphql_error)
logger.error(error_message)
return {'error': error_message}, status.HTTP_400_BAD_REQUEST
@app.route('/health-check')
@app.route('/ping')
def health_check():
"""
Health check
"""
return {'reply': 'pong'}
@app.route("/spec")
def spec():
swag = swagger(app)
swag['info']['version'] = "1.0"
swag['info']['title'] = "Demo of graphql API endpoint"
return swag
if __name__ == '__main__':
app.debug = app.config['DEBUG']
app.run(host='0.0.0.0', port=5000)