cpanel中的Python flask应用程序路由:只能访问根URL [英] Python flask app routing in cpanel: can only access root url

查看:66
本文介绍了cpanel中的Python flask应用程序路由:只能访问根URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在cPanel中设置了一个python应用程序.我已将应用程序URL设置为 backend ,当我查询 mydomain.com/backend/时,它会返回该应用程序的根视图(只是html"hello there").

I have a python app set up in cPanel. I have set the app URL to backend and when I query mydomain.com/backend/ it gives back the app's root view (which is just an html "hello there").

其余端点是我需要的,但我在每个其他URL上都返回了404

The rest of the endpoints are the ones I need but I get back a 404 on every other URL

@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.我在 public_html/.htaccess 中找不到对 backend/的任何引用.依赖关系还可以(没有软件包抱怨).

I would bet there's some other service returning the 404 before reaching the script. I could not find any reference to backend/ in the public_html/.htaccess. Dependencies are ok (no package complains).

我在服务器上的权限非常有限.任何指针将不胜感激.

My privileges on the server are very limited. Any pointers would be appreciated.

谢谢!

发现Ps 类似的问题,没有答案

推荐答案

我们团队的一名成员通过添加新的子域并在其中设置网址来解决了这个问题.

A member of our team worked this out by adding a new subdomain and setting the url there.

因此,该应用程序现在运行在 backend.mydomain.com/backend 上,并且运行正常.

So instead of mydomain.com/backend the app is running now at backend.mydomain.com/backend and working just fine.

欢呼

这篇关于cpanel中的Python flask应用程序路由:只能访问根URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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