如何在PythonAnywhere上部署web2py?

fuz*_*man 12 python web2py pythonanywhere

如何在PythonAnywhere上启动并运行基本的web2py服务器 ?

hwj*_*wjp 17

[更新 - 29/05]我们现在在网页标签上有一个大按钮,可以为您完成所有这些工作.只需点击它显示Web2Py的位置,填写您的管理员密码,您就可以开始了.

这是历史感兴趣的旧东西......

我是PythonAnywhere开发人员.我们不是大规模的web2py专家(但是?)但我设法让web2py运行起来并运行如下:

首先下载并解压缩web2py:

wget http://www.web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
Run Code Online (Sandbox Code Playgroud)

转到PythonAnywhere"Web"面板并编辑您的wsgi.py.添加以下行:

import os
import sys

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

from wsgihandler import application
Run Code Online (Sandbox Code Playgroud)

替换my_username您的用户名.

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

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

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

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

python web2py.py --port=80
Run Code Online (Sandbox Code Playgroud)

输入管理员密码

按ctrl-c

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

然后转到PythonAnywhere 上的Web面板,单击重新加载Web应用程序,事情应该有效!