Can not go to another page using url_for inside html tag in Flask [duplicate]Python Flask Render Text from Variable like render_templateUrl in browser not updated after call of redirect( url_for('xxx' )) in Flask with jQuery mobileFlask redirect(url_for) error with gunricorn + nginxCannot display HTML stringError processing Json requestTwitter oauth with flask_oauthlib, Failed to generate request tokenPython flask wont render multiple templates, possibly HTML issueFlask POSTs with Trailing Slashflask app gives 404 for non-root routeJinja ignores HTML commentsHow can I run an app script python in django (hosted in a2hosting)?
A Permanent Norse Presence in America
Reply 'no position' while the job posting is still there
Constructing Group Divisible Designs - Algorithms?
Why do IPv6 unique local addresses have to have a /48 prefix?
How much character growth crosses the line into breaking the character
Divine apple island
Find last 3 digits of this monster number
If a character with the Alert feat rolls a crit fail on their Perception check, are they surprised?
Is there a word to describe the feeling of being transfixed out of horror?
Global amount of publications over time
What (else) happened July 1st 1858 in London?
Can the Supreme Court overturn an impeachment?
How should I respond when I lied about my education and the company finds out through background check?
How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?
Confusion on Parallelogram
Is XSS in canonical link possible?
Greco-Roman egalitarianism
Translation of Scottish 16th century church stained glass
Drawing ramified coverings with tikz
Drawing a topological "handle" with Tikz
Using a siddur to Daven from in a seforim store
Proof of Lemma: Every nonzero integer can be written as a product of primes
Difference between -| and |- in TikZ
What is the grammatical term for “‑ed” words like these?
Can not go to another page using url_for inside html tag in Flask [duplicate]
Python Flask Render Text from Variable like render_templateUrl in browser not updated after call of redirect( url_for('xxx' )) in Flask with jQuery mobileFlask redirect(url_for) error with gunricorn + nginxCannot display HTML stringError processing Json requestTwitter oauth with flask_oauthlib, Failed to generate request tokenPython flask wont render multiple templates, possibly HTML issueFlask POSTs with Trailing Slashflask app gives 404 for non-root routeJinja ignores HTML commentsHow can I run an app script python in django (hosted in a2hosting)?
This question already has an answer here:
Python Flask Render Text from Variable like render_template
4 answers
I can not go to about_me
page from the index
page.
Error :
The requested URL was not found on the server.
and got url like "http://127.0.0.1:5000/%7B%7B%20url_for('about')%20%7D%7D"
.
from flask import Flask, redirect, url_for
app = Flask(__name__)
@app.route('/')
def index():
return '''
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
</head>
<body>
<p>welcome home</p>
<a href=" url_for('about_me') ">about</a>
</body>
</html>
'''
@app.route('/about')
def about_me():
return 'about me'
if __name__ == '__main__':
app.run(debug=True)
python flask url-for
marked as duplicate by davidism
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 8 at 13:19
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Python Flask Render Text from Variable like render_template
4 answers
I can not go to about_me
page from the index
page.
Error :
The requested URL was not found on the server.
and got url like "http://127.0.0.1:5000/%7B%7B%20url_for('about')%20%7D%7D"
.
from flask import Flask, redirect, url_for
app = Flask(__name__)
@app.route('/')
def index():
return '''
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
</head>
<body>
<p>welcome home</p>
<a href=" url_for('about_me') ">about</a>
</body>
</html>
'''
@app.route('/about')
def about_me():
return 'about me'
if __name__ == '__main__':
app.run(debug=True)
python flask url-for
marked as duplicate by davidism
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 8 at 13:19
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Python Flask Render Text from Variable like render_template
4 answers
I can not go to about_me
page from the index
page.
Error :
The requested URL was not found on the server.
and got url like "http://127.0.0.1:5000/%7B%7B%20url_for('about')%20%7D%7D"
.
from flask import Flask, redirect, url_for
app = Flask(__name__)
@app.route('/')
def index():
return '''
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
</head>
<body>
<p>welcome home</p>
<a href=" url_for('about_me') ">about</a>
</body>
</html>
'''
@app.route('/about')
def about_me():
return 'about me'
if __name__ == '__main__':
app.run(debug=True)
python flask url-for
This question already has an answer here:
Python Flask Render Text from Variable like render_template
4 answers
I can not go to about_me
page from the index
page.
Error :
The requested URL was not found on the server.
and got url like "http://127.0.0.1:5000/%7B%7B%20url_for('about')%20%7D%7D"
.
from flask import Flask, redirect, url_for
app = Flask(__name__)
@app.route('/')
def index():
return '''
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
</head>
<body>
<p>welcome home</p>
<a href=" url_for('about_me') ">about</a>
</body>
</html>
'''
@app.route('/about')
def about_me():
return 'about me'
if __name__ == '__main__':
app.run(debug=True)
This question already has an answer here:
Python Flask Render Text from Variable like render_template
4 answers
python flask url-for
python flask url-for
edited Mar 8 at 7:44
Tiw
4,24861630
4,24861630
asked Mar 8 at 6:33
PraveenPraveen
225
225
marked as duplicate by davidism
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 8 at 13:19
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by davidism
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Mar 8 at 13:19
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The formatting you're using to insert the url_for the about me page, namely:
<a href=url_for('about_me')">about</a>
Will only work inside of a Jinja template. Those templates get processed by the template engine before the response is returned, and during that processing the notation with the two braces something
gets recognized and interpreted differently.
Here however, you are not using this notation in a Jinja template, you are using it it in a normal string, a string that does not get processed and thus does not have anything replaced.
The correct way to achieve what you want, in this case would be to parameterize the string and pass the link through formatting. E.g:
@app.route('/')
def index():
return '''
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
</head>
<body>
<p>welcome home</p>
<a href="about_me">about</a>
</body>
</html>
'''.format(about_me=url_for('about_me'))
Hope this helps!
1
Thank you. I haven't thought of that.
– Praveen
Mar 8 at 12:46
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The formatting you're using to insert the url_for the about me page, namely:
<a href=url_for('about_me')">about</a>
Will only work inside of a Jinja template. Those templates get processed by the template engine before the response is returned, and during that processing the notation with the two braces something
gets recognized and interpreted differently.
Here however, you are not using this notation in a Jinja template, you are using it it in a normal string, a string that does not get processed and thus does not have anything replaced.
The correct way to achieve what you want, in this case would be to parameterize the string and pass the link through formatting. E.g:
@app.route('/')
def index():
return '''
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
</head>
<body>
<p>welcome home</p>
<a href="about_me">about</a>
</body>
</html>
'''.format(about_me=url_for('about_me'))
Hope this helps!
1
Thank you. I haven't thought of that.
– Praveen
Mar 8 at 12:46
add a comment |
The formatting you're using to insert the url_for the about me page, namely:
<a href=url_for('about_me')">about</a>
Will only work inside of a Jinja template. Those templates get processed by the template engine before the response is returned, and during that processing the notation with the two braces something
gets recognized and interpreted differently.
Here however, you are not using this notation in a Jinja template, you are using it it in a normal string, a string that does not get processed and thus does not have anything replaced.
The correct way to achieve what you want, in this case would be to parameterize the string and pass the link through formatting. E.g:
@app.route('/')
def index():
return '''
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
</head>
<body>
<p>welcome home</p>
<a href="about_me">about</a>
</body>
</html>
'''.format(about_me=url_for('about_me'))
Hope this helps!
1
Thank you. I haven't thought of that.
– Praveen
Mar 8 at 12:46
add a comment |
The formatting you're using to insert the url_for the about me page, namely:
<a href=url_for('about_me')">about</a>
Will only work inside of a Jinja template. Those templates get processed by the template engine before the response is returned, and during that processing the notation with the two braces something
gets recognized and interpreted differently.
Here however, you are not using this notation in a Jinja template, you are using it it in a normal string, a string that does not get processed and thus does not have anything replaced.
The correct way to achieve what you want, in this case would be to parameterize the string and pass the link through formatting. E.g:
@app.route('/')
def index():
return '''
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
</head>
<body>
<p>welcome home</p>
<a href="about_me">about</a>
</body>
</html>
'''.format(about_me=url_for('about_me'))
Hope this helps!
The formatting you're using to insert the url_for the about me page, namely:
<a href=url_for('about_me')">about</a>
Will only work inside of a Jinja template. Those templates get processed by the template engine before the response is returned, and during that processing the notation with the two braces something
gets recognized and interpreted differently.
Here however, you are not using this notation in a Jinja template, you are using it it in a normal string, a string that does not get processed and thus does not have anything replaced.
The correct way to achieve what you want, in this case would be to parameterize the string and pass the link through formatting. E.g:
@app.route('/')
def index():
return '''
<!DOCTYPE html>
<html lang="en">
<head>
<title>Title</title>
</head>
<body>
<p>welcome home</p>
<a href="about_me">about</a>
</body>
</html>
'''.format(about_me=url_for('about_me'))
Hope this helps!
answered Mar 8 at 7:15
Tom P.Tom P.
13016
13016
1
Thank you. I haven't thought of that.
– Praveen
Mar 8 at 12:46
add a comment |
1
Thank you. I haven't thought of that.
– Praveen
Mar 8 at 12:46
1
1
Thank you. I haven't thought of that.
– Praveen
Mar 8 at 12:46
Thank you. I haven't thought of that.
– Praveen
Mar 8 at 12:46
add a comment |