7

我有一个带有文件系统的工作示例站点(https://github.com/alvations/APE):

APE
    \app
        \templates
            base.html
            index.html
            instance.html
        __init__.py
        hamlet.py
    config.py
    run.py

我在https://www.pythonanywhere.com上创建了一个烧瓶项目,文件系统如下:

/home/alvations/
    /Dropbox/
    /mysite/
        /templates
            base.html
            index.html
            instance.html
        flask_app.py
    /web2py/

在此处输入图像描述

run.py在 pythonanywhere 项目中应该放在哪里?

如何在 pythonanywhere 上的 Github 中使用与我的项目相同的文件结构?

4

1 回答 1

7

PythonAnywhere 开发者在这里——你不需要 PythonAnywhere 上的run.py。通常进入那里的代码是运行可以为您的应用程序提供服务的本地 Flask 服务器——这一切都由我们的系统为您处理。

相反,您需要更改 WSGI 文件(从“Web”选项卡链接)以导入适当的应用程序模块。因此,因为您在 github 上的示例站点确实

from app import app
app.run(debug=True)

...在 WSGI 文件中的 PythonAnywhere 上,您需要执行以下操作:

from app import app as application

需要注意的一件事——如果我正确理解了您上面的文件列表,那么您并没有安装所有的 github 应用程序——只有模板。您将需要__init__.pyhamlet.pyconfig.py,并且它们需要与原始目录结构相同。

于 2014-11-17T13:19:24.563 回答