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)?

Domain expired, GoDaddy holds it and is asking more money

Why do UK politicians seemingly ignore opinion polls on Brexit?

What is the meaning of "of trouble" in the following sentence?

How could a lack of term limits lead to a "dictatorship?"

Is there a way to make member function NOT callable from constructor?

Could a US political party gain complete control over the government by removing checks & balances?

Is there a name of the flying bionic bird?

Why is the design of haulage companies so “special”?

Can I find out the caloric content of bread by dehydrating it?

LWC and complex parameters

"My colleague's body is amazing"

Copycat chess is back

Is there any use for defining additional entity types in a SOQL FROM clause?

If a centaur druid Wild Shapes into a Giant Elk, do their Charge features stack?

Can a planet have a different gravitational pull depending on its location in orbit around its sun?

Information to fellow intern about hiring?

Could Giant Ground Sloths have been a good pack animal for the ancient Mayans?

New order #4: World

Why is my log file so massive? 22gb. I am running log backups

What is it called when one voice type sings a 'solo'?

Can I legally use front facing blue light in the UK?

What does "enim et" mean?

"listening to me about as much as you're listening to this pole here"

Are objects structures and/or vice versa?



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)?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0
















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)









share|improve this question















marked as duplicate by davidism flask
Users with the  flask badge can single-handedly close flask questions as duplicates and reopen them as needed.

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.
























    0
















    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)









    share|improve this question















    marked as duplicate by davidism flask
    Users with the  flask badge can single-handedly close flask questions as duplicates and reopen them as needed.

    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.




















      0












      0








      0









      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)









      share|improve this question

















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 7:44









      Tiw

      4,39761730




      4,39761730










      asked Mar 8 at 6:33









      PraveenPraveen

      205




      205




      marked as duplicate by davidism flask
      Users with the  flask badge can single-handedly close flask questions as duplicates and reopen them as needed.

      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 flask
      Users with the  flask badge can single-handedly close flask questions as duplicates and reopen them as needed.

      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.
























          1 Answer
          1






          active

          oldest

          votes


















          1














          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!






          share|improve this answer


















          • 1





            Thank you. I haven't thought of that.

            – Praveen
            Mar 8 at 12:46

















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          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!






          share|improve this answer


















          • 1





            Thank you. I haven't thought of that.

            – Praveen
            Mar 8 at 12:46















          1














          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!






          share|improve this answer


















          • 1





            Thank you. I haven't thought of that.

            – Praveen
            Mar 8 at 12:46













          1












          1








          1







          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!






          share|improve this answer













          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!







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 8 at 7:15









          Tom P.Tom P.

          14516




          14516







          • 1





            Thank you. I haven't thought of that.

            – Praveen
            Mar 8 at 12:46












          • 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





          Popular posts from this blog

          1928 у кіно

          Захаров Федір Захарович

          Ель Греко