當前位置: 首頁>>代碼示例>>Python>>正文


Python app.run方法代碼示例

本文整理匯總了Python中app.app.run方法的典型用法代碼示例。如果您正苦於以下問題:Python app.run方法的具體用法?Python app.run怎麽用?Python app.run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app.app的用法示例。


在下文中一共展示了app.run方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: central_main

# 需要導入模塊: from app import app [as 別名]
# 或者: from app.app import run [as 別名]
def central_main():
    thread = Thread(target=schedule_main)
    thread.start()
    app.run(host='0.0.0.0', port=CENTRAL_PORT, debug=True)
    thread.join()
    print "Everything is finished." 
開發者ID:ls1intum,項目名稱:fogernetes,代碼行數:8,代碼來源:core.py

示例2: create

# 需要導入模塊: from app import app [as 別名]
# 或者: from app.app import run [as 別名]
def create():
    print("Initialising")
    init()
    application.run(host='127.0.0.1', port=5000) 
開發者ID:Azure,項目名稱:DevOps-For-AI-Apps,代碼行數:6,代碼來源:wsgi.py

示例3: stuff_before_request

# 需要導入模塊: from app import app [as 別名]
# 或者: from app.app import run [as 別名]
def stuff_before_request():
    if request.endpoint in ["get_doi_endpoint_v2", "get_doi_endpoint"]:
        email = request.args.get("email", None)
        if not email or email.endswith(u"example.com"):
            abort_json(422, "Email address required in API call, see http://unpaywall.org/products/api")

    if get_ip() in ["35.200.160.130", "45.249.247.101", "137.120.7.33",
                    "52.56.108.147", "193.137.134.252", "130.225.74.231"]:
        abort_json(429, "History of API use exceeding rate limits, please email support@unpaywall.org for other data access options, including free full database dump.")

    g.request_start_time = time()
    g.hybrid = 'hybrid' in request.args.keys()
    if g.hybrid:
        logger.info(u"GOT HYBRID PARAM so will run with hybrid.")

    # don't redirect http api in some cases
    if request.url.startswith("http://api."):
        return
    if "staging" in request.url or "localhost" in request.url:
        return

    # redirect everything else to https.
    new_url = None
    try:
        if request.headers["X-Forwarded-Proto"] == "https":
            pass
        elif "http://" in request.url:
            new_url = request.url.replace("http://", "https://")
    except KeyError:
        # logger.info(u"There's no X-Forwarded-Proto header; assuming localhost, serving http.")
        pass

    # redirect to naked domain from www
    if request.url.startswith("https://www.oadoi.org"):
        new_url = request.url.replace(
            "https://www.oadoi.org",
            "https://oadoi.org"
        )
        logger.info(u"URL starts with www; redirecting to " + new_url)

    if new_url:
        return redirect(new_url, 301)  # permanent



# convenience function because we do this in multiple places 
開發者ID:ourresearch,項目名稱:oadoi,代碼行數:48,代碼來源:views.py


注:本文中的app.app.run方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。