如何在 PythonAnywhere 上部署 web2py?

发布于 2024-12-19 17:11:02 字数 117 浏览 4 评论 0原文

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

弥繁 2024-12-26 17:11:02

[更新 - 29/05] 我们现在在网络选项卡上有一个大按钮,可以为您完成所有这些操作。只需点击显示 Web2Py 的位置,填写您的管理员密码,然后就可以开始了。

这是出于历史兴趣的旧内容...

我是一名 PythonAnywhere 开发人员。我们还不是大量的 web2py 专家(还?),但我已经成功地启动并运行了 web2py,如下所示:

首先下载并解压 web2py:

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

转到 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

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()

感谢 Juan Martinez 对这部分的说明,您可以在其中使用可以在这里查看:
http://web2py.pythonanywhere.com/

然后打开 Bash 控制台,然后 cd< /code> 进入主 web2py 文件夹,然后运行

python web2py.py --port=80

​​输入管理员密码

按 ctrl-c

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

然后转到您的 Web 面板上PythonAnywhere,单击重新加载网络应用程序
一切都应该有效!

[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...

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

First download and unpack web2py:

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

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

replacing my_username with your username.

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()

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

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

python web2py.py --port=80

enter admin password

press ctrl-c

(this will generate the parameters_80.py config file)

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

吲‖鸣 2024-12-26 17:11:02

您也可以简单地运行此 bash 脚本:

http://pastebin.com/zcA5A89k

管理将被禁用,因为没有HTTPS,除非您像上一篇文章中那样绕过它。它将产生安全漏洞。

You can also simply run this bash script:

http://pastebin.com/zcA5A89k

admin will be disabled because of no HTTPS unless you bypass it as in the previous post. It will create a security vulnerability.

一身骄傲 2024-12-26 17:11:02

Pastebin 已关闭,我从缓存中检索了此内容。

cd ~
wget -O web2py_srz.zip http://web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
echo "
PATH = '/home/"`whoami`"/web2py'
import os
import sys
sys.stdout = sys.stderr
os.chdir(PATH)
if not './' in sys.path[:1]: sys.path.insert(0,'./')
from gluon.main import wsgibase as application
" > /var/www/wsgi.py
cd web2py
python -c "from gluon.main import save_password; save_password(raw_input('admin  password: '),433)"

Pastebin was down, I retrieved this from the cache.

cd ~
wget -O web2py_srz.zip http://web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
echo "
PATH = '/home/"`whoami`"/web2py'
import os
import sys
sys.stdout = sys.stderr
os.chdir(PATH)
if not './' in sys.path[:1]: sys.path.insert(0,'./')
from gluon.main import wsgibase as application
" > /var/www/wsgi.py
cd web2py
python -c "from gluon.main import save_password; save_password(raw_input('admin  password: '),433)"
酒几许 2024-12-26 17:11:02

我最近在 这里总结了在 PythonAnywhere 上部署 Web2Py 的经验

希望它有所帮助
新托伦

I have recently summarized my experience with deployment of Web2Py on PythonAnywhere here

Hope it helps
NeoToren

半透明的墙 2024-12-26 17:11:02

我会尝试在讨论中添加一些新内容。我发现的最简单的方法是在未登录时转到此处。这样您就不必摆弄终端:

https://www.pythonanywhere.com/try-web2py

提供一个域名,然后您将被重定向到显示您的登录信息和创建的仪表板的页面对于该域。只需从那里创建一个帐户,这样您的应用程序就不会在 24 小时后被删除。当您注册时,您的应用程序有 3 个月的有效期(如果您不付款)。我相信这是一项新政策。然后只需转到 https://appname.pythonanywhere.com/admin 然后输入您获得的密码然后将您的 Web2Py 文件上传到仪表板,然后访问该页面。

我不确定如何在 PythonAnywhere 上为现有帐户上传 Web2Py 应用程序,但这是我找到的最简单的方法。

I'll try to add something new to the discussion. The EASIEST way I've found is to go here when you aren't logged in. This makes it so you don't have to mess around with the terminal:

https://www.pythonanywhere.com/try-web2py

Come up with a domain name, then you'll get redirected to a page showing your login information and created dashboard for that domain. From there just create an account so your app isn't erased after 24 hours. When you sign up, your app has a 3 month expiry date (if you're not paying). I believe this is a new policy. Then simply go to https://appname.pythonanywhere.com/admin and then enter the password you were given and then upload your Web2Py file into the dashboard and then visit the page.

I'm not sure how to upload a Web2Py app on PythonAnywhere for an existing account, but that's the easiest method I've found.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文