当前位置: 首页>>代码示例>>Python>>正文


Python FlaskAPI.debug方法代码示例

本文整理汇总了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()
开发者ID:yanguanglan,项目名称:wechat_web_scraper,代码行数:32,代码来源:web.py

示例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)
开发者ID:EricSchles,项目名称:flask-graphql-example,代码行数:32,代码来源:api.py


注:本文中的flask.ext.api.FlaskAPI.debug方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。