當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。