Issue
Here is my code I also tried it without quotes but it gives me ('html' is not defined) error
@app.route('/entry')
def entry_page() -> 'html':
return render_template('entry.html',
the_title='Welcome to searchtools on the web!')
app.run()
Solution
That's not how annotations work
->
is a syntax meant to mention the type
of data being returned.
To annotate functions there are various methods.
Method 1: Commenting (also known as single line comment)
def function(a): # Annotation
return a
Method 2: String Literal (also known as multi line or docstring comment)
def function(a):
"""
Returns the value passed
"""
return a
Method 1 is recommend for small comments (for your case) Method 2 is recommended for big comments
Answered By - The Myth
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.