Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
312 views
in Technique[技术] by (71.8m points)

python - web.py invalid syntax template traceback

I started learning web.py by following the Udemy tutorial by Joseph Delgadillo. I've tried to render a template and run the code, but constantly get this error and i don't know why. The error always says that there is a syntax error on line 6 no matter how much i change the spacing and other stuff.

invalid syntax

Template traceback:
    File 'D:\Projects\python_proj\PythonNew\learning\webstuff\webpy\resources\main.html', line 6
        None (main.html, line 6)

Here's the python code

import web

urls = (
    "/(.*)/(.*)", "index"
    )

render = web.template.render("D:\Projects\python_proj\PythonNew\learning\webstuff\webpy\resources\")
app = web.application(urls, globals())

class index:
    def GET(self, name, age):
        return render.main(name, age)

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

For the file path, I found out that i must define the whole file path or I would get an error saying that the template doesn't exist. Here's the html main.html

$def with (name, age)

<h1>Name: $name</h1>
<p>Your current age is $age</p>

I searched all over StackOverflow, but couldn't find a single answer, even though there where questions like mine. Also sorry if the code snipets don't turn out like they should be, I'm new to stackoverflow.

question from:https://stackoverflow.com/questions/66067798/web-py-invalid-syntax-template-traceback

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...