Reputation: 556
I have a flask project where I have an endpoint that returns return ''' <h1> Inserted succesfully . Click this link to <a href = "moviehome.html"> go to home page </a> </h1> '''
where I want to click on the href text "go to home page"
to return to my home page . However when I click on it I get a
404 URL not found on the server
error . I also tried <a href = "{{url_for('home')}}">
inserting the name of my endpoint but the result was the same
My home endpoint :
#home page
@app.route('/')
def home():
return render_template('moviehome.html')
I would appreciate you help with this issue . Thank you in advance.
Upvotes: 0
Views: 111
Reputation: 4254
return '''
<h1> Inserted succesfully . Click this link to
<a href = "{{ url_for('home') }}"> go to home page </a>
</h1>
'''
you are returning just a plain string with docstring
letteral, the jijna2
expression is not parsed but interpreted as string.
the solution is to use string concatenation like
return '''
<h1> Inserted succesfully . Click this link to
<a href = " ''' + url_for('home') + ''' "> go to home page </a>
</h1>
'''
Upvotes: 1