0
時,我在web.py中出現404錯誤,這是我的代碼和我的問題。當使用/(.+)(新手Q)
import web
render = web.template.render('templates/')
urls = (
'/(.+)', 'index'
)
class index:
def GET(self, lang):
return render.index(lang)
if __name__=="__main__":
app = web.application(urls, globals())
app.run()
和我的index.html是這個:
$def with (lang)
$if lang == 'en':
I just wanted to say <em>hello</em>
$elif lang =='es' or lang == '':
<em>Hola</em>, mundo!
$else:
página no disponible en este idioma
的問題是,當我運行此代碼,我得到一個404錯誤。我認爲這個問題可能是URL部分,特別是/(.+)。我想我沒有正確使用它,我想讓它工作,以便我可以使用多個參數。當我使用/(.*)時,它可以工作,但不能用於多個參數,並且文檔說對於超過1個參數,我必須使用+而不是*
事先感謝。