簡體   English   中英

在同一過程中托管多個應用(燒瓶,nginx和uwsgi)

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM