简单的Web.py代码无效

时间:2018-06-13 07:05:03

标签: python python-3.x web web.py visual-web-developer

我正在关注web.py教程,我尝试编写这个对我来说不起作用的简单代码,即使URL映射完成正确,也正确定义了类。

以下是代码:

    import web

urls = {
    '/', 'home'

}

render = web.template.render("Views/Templates", base="MainLayout")
app = web.application(urls, globals())


class home:
    def GET(self):
        return render.Home()


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

和 MainLayout.html是:

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CodeWizard</title>
    <link rel="stylesheet" href="Static\css\bootstrap.min.css" />
    <link rel="stylesheet" href="Static\css\bootstrap-material-design.css" />

</head>
<body>
    <div id="app">
        <nav class="navbar navbar-expand-sm navbar-light bg-primary navbar-fixed-top">
            <div class="container">
                <a class="navbar-brand" href="#">GrapeSoda</a>
                <ul class="navbar-nav">
                    <li class="nav-item"><a class="nav-link" href="/home">Home</a></li>
                </ul>
                <ul class="navbar-nav">
                    <li class="nav-item"><a class="nav-link" href="/about">About</a></li>
                </ul>
                <ul class="navbar-nav">
                    <li class="nav-item"><a class="nav-link" href="/services">Services</a></li>
                </ul>
                <ul class="navbar-nav">
                    <li class="nav-item"><a class="nav-link" href="/contact">Contact</a></li>
                </ul>
                <ul class="navbar-nav">
                    <li class="nav-item"><a class="nav-link" href="/register">Register</a></li>
                </ul>
        </nav>
    </div>
        $:page
    </div>
</body>
</html>

它显示的错误是:

Traceback (innermost first)

_match中的C:\ Users \ user \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ web.py-0.40.dev0-py3.6.egg \ web \ application.py         for pat,映射中的内容:...

句柄中的C:\ Users \ user \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ web.py-0.40.dev0-py3.6.egg \ web \ application.py         fn,args = self._match(self.mapping,web.ctx.path)...

C:\ Users \ user \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ web.py-0.40.dev0-py3.6.egg \ web \ application.py正在处理中                     return self.handle()...

0 个答案:

没有答案