I was following a web.py tutorial and I tried writing this simple code that didn't work for me, even the URL mapping is done correct, also the classes are define properly.
Here is the code:
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()
and the MainLayout.html is:
<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>
And the error it shows is:
Traceback (innermost first)
C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\web.py-0.40.dev0-py3.6.egg\web\application.py in _match for pat, what in mapping: ...
C:\Users\user\AppData\Local\Programs\Python\Python36-32\lib\site-packages\web.py-0.40.dev0-py3.6.egg\web\application.py in handle 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 in process return self.handle() ...
Aucun commentaire:
Enregistrer un commentaire