504网关超时服务器在tim中没有响应

2024-10-03 09:19:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我用虚拟机运行我的烧瓶应用程序sqtf。她使用127.0.0.1:5000进行本地操作,但不使用我的apache服务器。我使用python3.6、apache2.4和mod wsgi。 这是我项目的简化结构:

/var/www/squashPy/src/squash_test_filter/
                              /sqtf
                                  sqtf.wsgi
                                  __init__.py
                                  /static
                                  /templates
                              /venv

配置虚拟主机后'sqtf.com.conf“在阿帕奇和我的sqtf.wsgi公司(同时配置我的virtualenv和/etc/hosts),服务器将在www.sqtf.com网站但在我的登录页面或其他页面上,'www.sqtf.com/auth/login'504网关超时服务器端口80。在

在我的错误.log公司名称:

从deamon进程“sqtf”读取响应时超时:/var/www/squashPy/src/squash_test_filter/sqtf/sqtf.wsgi公司在

我在我的死亡进程中添加了一个python home。 增加超时不会改变任何东西。在

我的sqtf.com.conf在

^{pr2}$

我的sqtf.wsgi公司在

    activate_this='/var/www/..../venv/bin/activate_this.py'
    with open(activate_this) as file_:
            exec(file_.read(), dict(__file__=activate_this))
    import sys
    import logging
    sys.path.insert(0, "/var/www/squashPy/src/squash_test_filter/")
    from sqtf import app as application

我的/etc/hosts的一部分:

    127.0.0.1 localhost
    127.0.1.1 ubuntu
    127.0.0.1 www.sqtf.com sqtf.com sqtf

    # etc ...

my/sqtf/init的一部分

    import ...



    def create_app(test_config=None):
        # create and configure the app

        app = Flask(__name__, instance_relative_config=True)
        api = Api(app)

        app.config.from_mapping(
            SECRET_KEY='dev',
            DATABASE=os.path.join(app.instance_path, 'sqtf.sqlite'),
        )

        if test_config is None:
            # load the instance config, if it exists, when not testing
            app.config.from_pyfile('config.py', silent=True)
        else:
            # load the test config if passed in
            app.config.from_mapping(test_config)

        # ensure the instance folder exists
        try:
            os.makedirs(app.instance_path)
        except OSError:
            pass
        db.init_app(app)
        return app

Tags: pathinstancefromtestimportcomconfigapp
1条回答
网友
1楼 · 发布于 2024-10-03 09:19:27

我解决了这个问题,如果您使用烧瓶工厂,例如create\u app,您需要通过以下方式更改.wsgi中的from sqtf import app as application行:

from sqtf import create_app
application=create_app()

相关问题 更多 >