![](/img/trans.png)
[英]Docker Image with uWSGI/Gunicorn + Nginx for Flask apps in CentOS
[英]Hosting multiple apps in the same process (flask, nginx, and uwsgi)
在安装点下托管应用程序时( http://uwsgi-docs.readthedocs.io/en/latest/Nginx.html#hosting-multiple-apps-in-the-same-process-aka-managing-script-name-and -path-info ),即:myserver.com/home-> myserver.com/myproject/home,路径不会更改为新URL
以下html文件位于myserver.com/myproject/* home.html下
This is <a href='/home'>HOME</a>
#<!-- page is linked to myserver.com/home instead of myserver.com/myproject/home -->
Please login <a href='/login'>HERE</a>
#<!-- page is linked to myserver.com/login instead of myserver.com/myproject/login -->
{{ request.path }}
#<!-- will display myserver.com/home -->
login.html
<form action='/login' method='post'>
<input type='text' name='username'>
<input type='password' name='password'>
<input type='submit'>
</form>
#<!-- post request is submitted to myserver.com/login instead of myserver.com/myproject/login -->
main.py =烧瓶路线
@app.route('/home')
return render_template('home.html')
@app.route('/login')
return render_template('login.html')
这是我的目录结构:
myproject/
|__app/
|____main.py
|____static/ #js and css are located (working)
|____templates/ #html files are located
|________home.html #page is rendered but relative links are still pointing to old URL
|________login.html
|__venv/ #virtual environment
|__run.py #uwsgi module
|__myproject.ini #set mount = /myproject=run.py
|__myproject.sock
更新:刚刚发现request.script_root与request.path的区别
有人可以帮我设置request.script_root的相对路径吗
我仍然没有解决这个问题,但是,我只对所有我认为更好的链接使用了url_for
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.