在 1&1 共享主机上部署 Flask 应用程序(使用 CGI) [英] Deploy flask application on 1&1 shared hosting (with CGI)

查看:33
本文介绍了在 1&1 共享主机上部署 Flask 应用程序(使用 CGI)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用flask web 框架为我的体育俱乐部编写了一个web 应用程序.我使用内置测试服务器在本地机器上完成了所有工作.

I've written a web application for my sports club with the flask web framework. I did everything on my local machine with the build-in test server.

知道他们告诉我将其部署在 1&1 共享托管网络空间上.他们有 python 支持,但似乎他们只允许 CGI 运行 python 脚本.

Know they told me to deploy it on an 1&1 shared hosting web space. They have python support but it seems like they only allow CGI to run python scripts.

我试过这个教程:flask via CGI

直到现在我都忽略了重写的东西.对我的 CGI 脚本的所有请求都导致 404 错误.我修改了应用程序中的 404 处理程序以返回 request.path.当我请求/foo/runserver.cgi/它返回/作为输出.我不知道为什么它不提供索引视图.它不适用于任何视图,我总是收到 404.

I ignored the rewrite stuff until now. All requests to my CGI script resulted in a 404 error. I modified my 404 handler in the application to return request.path. When I request /foo/runserver.cgi/ it returns / as output. I have no idea why it doesn't serve the index view. It doesn't work with any view, I always get a 404.

亲切的问候,塞巴斯蒂安

Kind regards, Sebastian

推荐答案

我找到了解决方案!我将 /$1 与我的 .htaccess 分开并稍微修改了 werkzeug,因为 CGI 中的环境变量的命名与 WSGI 应用程序中的命名有点不同.我会通知 werkzeug 开发人员这件事,也许他会将我的解决方案包含在 werkzeug 中.

I found a solution! I left the /$1 away from my .htaccess and modified werkzeug a bit because the environment variables in CGI are named a bit different the in WSGI applications. I'll inform the werkzeug developer about it and maybe he'll include my solution into werkzeug.

这篇关于在 1&1 共享主机上部署 Flask 应用程序(使用 CGI)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆