python - cpanel中的Python烧瓶应用程序路由:只能访问root url
问题描述
我在 cPanel 中设置了一个 python 应用程序。我已将应用程序 URL 设置为backend
,当我查询时mydomain.com/backend/
,它会返回应用程序的根视图(这只是一个 html“你好”)。
其余端点是我需要的,但我在每个其他 URL 上都返回 404
@app.route('/')
def hello_world():
logger.debug("Hi there")
return "<h1 style='color:red'>Hi there</h1>"
@app.route('/test', methods=['POST','GET'])
def test():
logger.info("Got test request")
return {'ok' : 'success!'}
mydomain.com/backend/ --> Hi there
mydomain.com/backend/test --> 404
mydomain.com/backend/<any_other> --> 404
我敢打赌,在到达脚本之前,还有其他一些服务会返回 404。我backend/
在public_html/.htaccess
. 依赖关系没问题(没有包抱怨)。
我在服务器上的权限非常有限。任何指针将不胜感激。
谢谢!
ps发现了一个类似的问题没有答案
解决方案
将以下规则添加到应用程序 url 目录中的 .htaccess
RewriteEngine on
RewriteRule ^http://%{HTTP_HOST}%{REQUEST_URI} [END,NE]
为我解决了这个问题
推荐阅读
- hsqldb - HSQLDB - 更改过程的特定名称
- paper-elements - Lit-html 中纸质下拉菜单的事件监听器
- python-3.x - 在 Python 中通过 SOCKS5 代理进行 FTPS
- exception - 在控制台应用程序中解析 ILogger 时出错
- python - 创建一个包含字典的列表,其值是从不同的列表中顺序选择的
- c++ - osstringstream 抛出表达式必须是左值或函数指示符错误
- cron - 为什么我的 GKE cronjob 在运行 `echo` 后没有退出?
- c# - HttpContext.Current.GetOwinContext().Authentication.Challenge() 不打开 adfs 页面
- c++ - 所有按钮都应该包含对 MVC 代码 (C++) 中控制器的引用吗?
- javascript - 将类名添加到数据表的 td(列)