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 gram­mat­i­cal 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)?













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,24861630




      4,24861630










      asked Mar 8 at 6:33









      PraveenPraveen

      225




      225




      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.

          13016




          13016







          • 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

          Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

          2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme