如何在 PythonAnywhere 上部署 web2py?

如何在 PythonAnywhere 上部署 web2py?

问题描述:

我如何启动并运行一个基本的 web2py 服务器PythonAnywhere?

How do i get a basic web2py server up and running on PythonAnywhere?

[update - 29/05] 我们现在在 Web 选项卡上有一个大按钮,可以为您完成所有这些事情.只需点击显示 Web2Py 的位置,填写您的管理员密码,即可开始使用.

[update - 29/05] We now have a big button on the web tab that will do all this stuff for you. Just click where it says Web2Py, fill in your admin password, and you're good to go.

这里是具有历史意义的旧东西......

Here's the old stuff for historical interest...

我是一名 PythonAnywhere 开发人员.我们不是大型 web2py 专家(还不是?)但我已经设法让 web2py 像这样启动并运行:

I'm a PythonAnywhere developer. We're not massive web2py experts (yet?) but I've managed to get web2py up and running like this:

首先下载并解压 web2py:

First download and unpack web2py:

wget http://www.web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip

转到 PythonAnywhereWeb"面板并编辑您的 wsgi.py.添加这些行:

Go to the PythonAnywhere "Web" panel and edit your wsgi.py. Add these lines:

import os
import sys

path = '/home/my_username/web2py'
if path not in sys.path:
    sys.path.append(path)

from wsgihandler import application

用您的用户名替换 my_username.

您还需要注释掉 wsgi.py 中的最后两行,其中我们有默认的 hello world web.py 应用程序...

You will also need to comment out the last two lines in wsgi.py, where we have the default hello world web.py application...

# comment out these two lines if you want to use another framework
#app = web.application(urls, globals())
#application = app.wsgifunc()

感谢 Juan Martinez 对这部分的说明,您可以在此处查看:http://web2py.pythonanywhere.com/

Thanks to Juan Martinez for his instructions on this part, which you can view here: http://web2py.pythonanywhere.com/

然后打开一个 Bash 控制台,将 cd 放入主 web2py 文件夹,然后运行

then open a Bash console, and cd into the main web2py folder, then run

python web2py.py --port=80

输入管理员密码

按 ctrl-c

(这将生成 parameters_80.py 配置文件)

(this will generate the parameters_80.py config file)

然后转到 PythonAnywhere 上的 Web 面板,点击重新加载 Web 应用,一切正常!

then go to your Web panel on PythonAnywhere, click reload web app, and things should work!