I am new to web.py
and I tried making a simple application where I retrieve a HTML file and display it.
Here is my complete code:
import web
render = web.template.render('templates/')
urls = (
'/(.*)', 'index'
)
class index:
def GET(self):
return render.index()
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()
When I run this, I get the error message:
<class 'TypeError'>
at /GET() takes 1 positional argument but 2 were given
Whenever I add a random parameter to the GET function, the page is able to function, but otherwise not. It would be great if someone could point out what is going wrong here.
(.*)
will be used as second argument, change your code
class index:
def GET(self, name):
return render.index(name)
and template index.html
$def with (name)
<html>
<head>
<title>Hello $name</title>
</head>
<body>
Hello $name
</body>
</html>
now try open http://127.0.0.1:8080/John