I started to learn webpy in python and I wrote a simple code. but I have an error. please help me.
python code: import web
urls = ( '/(.)/(.)', 'index' ) render = web.template.render('resources/') app = web.application(urls, globals())
class index: def GET(self, name, age): return render.main(name, age)
if name == "main": app.run()
HTML code: $def whit (name,age)
Name: $name
Your age is: $age
Error: File "E:\Python_project\just_for_test\venv\lib\site-packages\web\application.py", line 289, in process return self.handle()
File "E:\Python_project\just_for_test\venv\lib\site-packages\web\application.py", line 280, in handle return self._delegate(fn, self.fvars, args)
File "E:\Python_project\just_for_test\venv\lib\site-packages\web\application.py", line 530, in _delegate return handle_class(cls)
File "E:\Python_project\just_for_test\venv\lib\site-packages\web\application.py", line 508, in handle_class return tocall(*args)
File "E:\Python_project\just_for_test\web\main.py", line 12, in GET return render.main(name, age)
File "E:\Python_project\just_for_test\venv\lib\site-packages\web\template.py", line 1135, in getattr t = self._template(name) File "E:\Python_project\just_for_test\venv\lib\site-packages\web\template.py", line 1132, in _template return self._load_template(name)
File "E:\Python_project\just_for_test\venv\lib\site-packages\web\template.py", line 1107, in _load_template return Template( File "E:\Python_project\just_for_test\venv\lib\site-packages\web\template.py", line 942, in init code = self.compile_template(text, filename)
File "E:\Python_project\just_for_test\venv\lib\site-packages\web\template.py", line 1019, in compile_template compiled_code = compile(code, filename, "exec")
File "E:\Python_project\just_for_test\resources\main.html", line 7 def whit (name,age) ^ SyntaxError: invalid syntax
Template traceback: File 'E:\Python_project\just_for_test\resources\main.html', line 7 None
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire