第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

flask 中url中重定向問題,參數(shù)傳遞

flask 中url中重定向問題,參數(shù)傳遞

胖貓CAT 2019-11-27 11:14:25
from?flask?import?Flask,?url_for from?werkzeug.utils?import?redirect app?=?Flask(__name__) @app.route('/admin') def?hello_admin(): ???return?'Hello?Admin' @app.route('/guest/') def?hello_guest(guest): ???return?'Hello?%s?as?Guest'?%?guest @app.route('/user/') def?hello_user(name): ???if?name?=='admin': ??????return?redirect(url_for('hello_admin')) ???else: ??????return?redirect(url_for('hello_guest'),?guest?=?name) ??????#?if?__name__?==?'__main__': #????app.run(debug?=?True) if?__name__?==?'__main__': ???app.run(debug=True)1、運(yùn)行 http://127.0.0.1:5000/admin 顯示?Hello?Admin?運(yùn)行正常2、但是運(yùn)行http://127.0.0.1:5000/user/?? ?顯示如下錯(cuò)誤:TypeErrorTypeError:?hello_user()?missing?1?required?positional?argument:?'name'?3、再次運(yùn)行http://127.0.0.1:5000/user/admin? ?顯示如下錯(cuò)誤: Not?FoundThe?requested?URL?was?not?found?on?the?server.?If?you?entered?the?URL?manually?please?check?your?spelling?and?try?again.?4、再次運(yùn)行http://127.0.0.1:5000/user/aaa顯示如下錯(cuò)誤:Not?FoundThe?requested?URL?was?not?found?on?the?server.?If?you?entered?the?URL?manually?please?check?your?spelling?and?try?again.?第3、4次運(yùn)行中是不是我的輸入是錯(cuò)誤導(dǎo)致的?那么參數(shù)應(yīng)該怎么傳呢??5、因?yàn)橐陨洗a是教程中到源代碼,應(yīng)該是沒有錯(cuò)的。后來我修改了源代碼中@app.route('/user/<name>')加入了<name>這個(gè)參數(shù)。運(yùn)行??http://127.0.0.1:5000/admin和?http://127.0.0.1:5000/user/admin?都顯示Hello?Admin?運(yùn)行正常。但是運(yùn)行http://127.0.0.1:5000/user/kjkj顯示如下錯(cuò)誤:TypeErrorTypeError:?redirect()?got?an?unexpected?keyword?argument?'guest'請(qǐng)問問題到底出在哪里呢??
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 3434 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)