简体   繁体   English

使用web.py渲染多个模板

[英]Rendering multiple templates with web.py

Ive recently gotten into Webdesign in Python, I've tried multiple frameworks but web.py seems to be my favorite except for one problem. 我最近用Python进入了Webdesign,我尝试了多种框架,但是web.py似乎是我的最爱,除了一个问题。 I cant seem to figure out how to make multiple pages with multiple templates.... 我似乎无法弄清楚如何使用多个模板制作多个页面。

here is my code so far: 到目前为止,这是我的代码:

import web

urls = (

'/', 'index', '/login/', 'login'


)

app = web.application(urls, globals())
render = web.template.render('templates/')

class index():
    def GET(self):
        return render.index()
class login():
    def GET(self):
        return render.login()



if __name__ == '__main__':
    app.run()

I get an error when I try to go to the login page :/ 当我尝试进入登录页面时出现错误:/

Try changing your url mapping: 尝试更改您的网址映射:

urls = (
    '/', 'index', 
    '/login/?', 'login',
)

/login/? will work for /login and /login/ url paths. 将适用于/login/login/网址路径。

It will be better if you show an exception that you get. 如果显示一个异常,那会更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM