我在 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/
in the public_html/.htaccess
。依赖关系正常(没有包抱怨)。
我在服务器上的权限非常有限。任何指示将不胜感激。
Thanks!
发现PS类似的问题 https://stackoverflow.com/questions/62708637/routing-pages-using-flask-and-deploying-on-cpanel没有答案
将以下规则添加到应用程序 url 目录中的 .htaccess
RewriteEngine on
RewriteRule ^http://%{HTTP_HOST}%{REQUEST_URI} [END,NE]
这为我解决了这个问题
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)