[英]Deploying a Flask app to shared hosting at godaddy
I got shared economy hosting at godaddy, and I finally got cgi working with python.我在 Godaddy 获得了共享经济托管,并且我终于让 cgi 使用了 python。 I created a simple cgi script:
我创建了一个简单的 cgi 脚本:
#!/../bin/python
print "Content-type: text/html\n\n"
print "<body bgcolor='000'>"
print "<font face='Courier New' color='white'>Test python page. CGI extension </font>"
print "</body>"
and that works just fine as you can see here: http://jottingdown.com/pytest.cgi Now I would like to deploy my hello world flask app so I follow the guide on the flask website http://flask.pocoo.org/docs/deploying/cgi/ and other guides on how to deploy a website using cgi but I keep getting error 500 http://jottingdown.com/flask/test.cgi .而作品就好了,你可以在这里看到: http://jottingdown.com/pytest.cgi现在我想,所以我跟着烧瓶网站上的指导,部署我的Hello World程序烧瓶HTTP://flask.pocoo。 org/docs/deploying/cgi/和其他关于如何使用 cgi 部署网站的指南,但我不断收到错误 500 http://jottingdown.com/flask/test.cgi 。
My test.cgi script:我的 test.cgi 脚本:
#!/../bin/python
from wsgiref.handlers import CGIHandler
from Flask_HelloWorld import app
CGIHandler().run(app)
My Flask_HelloWorld script:我的 Flask_HelloWorld 脚本:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run()
Do anybody know what I'm doing wrong, or got any experience with deploying to godaddy?有人知道我做错了什么,或者有任何部署到 Godaddy 的经验吗?
I see this question doesn't have an accepted answer.我看到这个问题没有公认的答案。 The directory structure, content in the .htaccess file also matters when depliying in shared hosting.
在共享主机中部署时,.htaccess 文件中的目录结构和内容也很重要。
Below link has a detailed description on deploying flask app in Apache shared hosting下面的链接详细描述了在 Apache 共享托管中部署 Flask 应用程序
https://medium.com/@mohdejazsiddiqui/deploy-flask-app-in-apache-shared-hosting-5b3c82c8fd5e https://medium.com/@mohdejazsiddiqui/deploy-flask-app-in-apache-shared-hosting-5b3c82c8fd5e
Hope it helps.希望能帮助到你。
Add .htaccess
to the web directory将
.htaccess
添加到 web 目录
#.htaccess
Options +ExecCGI
AddHandler cgi-script .cgi .py
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /cgi-bin/test.cgi/$1 [L]
Assuming you have the shared hosting directory like:假设您拥有共享托管目录,例如:
shared_root_directory/
---- CGI-bin/
---- test.cgi
---- Flask_HelloWorld.py
---- web/
---- .htaccess
Both Flask_HelloWorld.py
and test.cgi
must be/have "755" file permission. Flask_HelloWorld.py
和test.cgi
必须是/具有“755”文件权限。
You might want to take a took at this:您可能想了解一下:
http://flask.pocoo.org/docs/deploying/cgi/ http://flask.pocoo.org/docs/deploying/cgi/
The docs that vokuheila cites are the ones to read, but they are not quite complete. vokuheila 引用的文档是值得阅读的文档,但它们并不完整。 I too struggled with 500 errors.
我也遇到了 500 个错误。 See my post to this related stackoverflow question .
请参阅我对此相关计算器溢出问题的帖子。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.