在挂载点(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,路径未更改为新网址
以下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的相对路径