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

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved