Questions tagged [url-for]

url_for is a function present in web frameworks like Rails and Flask, used to get the URL for a given route.

184 questions
71
votes
1 answer

Where do I define the domain to be used by url_for() in Flask?

When I call url_for('index') it will generate '/' but there are times where I'd like it to generate 'domain.tld/' instead. I can't find in the documentation where I would specify this. Do I just need to do 'domain.tld/%s' % url_for('index')?
Mark
  • 1,367
  • 4
  • 12
  • 17
42
votes
4 answers

rails get app root/base url

In my app I have a few APIs that under api domain. Now in one of the API I want to generate a url that pointing to the main domain, say test.com/blabla... I tried to use url_for but seems the default root_url or request.host is in api domain.…
Bruce Xinda Lin
  • 2,470
  • 6
  • 24
  • 37
42
votes
1 answer

Creating link to an url of Flask app in jinja2 template

In my Flask app, I have a view which displays a post @post_blueprint.route('/post///') def get_post(year,month,title): # My code To display the last 10 entries, I have following…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/flask" class="post-tag grid--cell" title="show questions tagged 'flask'" rel="tag">flask</a> <a href="../../questions/tagged/jinja2" class="post-tag grid--cell" title="show questions tagged 'jinja2'" rel="tag">jinja2</a> <a href="../../questions/tagged/url-for" class="post-tag grid--cell" title="show questions tagged 'url-for'" rel="tag">url-for</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 20 '12 at 17:28">asked Jun 20 '12 at 17:28</time> <a href="../../users/679047/codecool" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/679047.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="codecool" onerror="onImageLoadingError(this);" /> </a> <div class="s-user-card--info"> <a href="../../users/679047/codecool" class="s-user-card--link">codecool</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">5,148</li> <li class="s-award-bling s-award-bling__gold" title="4 gold badges">4</li> <li class="s-award-bling s-award-bling__silver" title="24 silver badges">24</li> <li class="s-award-bling s-award-bling__bronze" title="35 bronze badges">35</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-10314800"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>42</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>8</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/10314800/flask-url-for-urls-in-javascript" class="question-hyperlink">Flask url_for URLs in Javascript</a></h3> <div class="excerpt">What is the recommended way to create dynamic URLs in Javascript files when using flask? In the jinja2 templates and within the python views url_for is used, what is the recommended way to do this in .js files? Since they are not interpreted by the…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/javascript" class="post-tag grid--cell" title="show questions tagged 'javascript'" rel="tag">javascript</a> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/flask" class="post-tag grid--cell" title="show questions tagged 'flask'" rel="tag">flask</a> <a href="../../questions/tagged/url-for" class="post-tag grid--cell" title="show questions tagged 'url-for'" rel="tag">url-for</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Apr 25 '12 at 11:37">asked Apr 25 '12 at 11:37</time> <a href="../../users/224732/erik-rothoff" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/224732.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Erik Rothoff" onerror="onImageLoadingError(this);" /> </a> <div class="s-user-card--info"> <a href="../../users/224732/erik-rothoff" class="s-user-card--link">Erik Rothoff</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">4,088</li> <li class="s-award-bling s-award-bling__gold" title="8 gold badges">8</li> <li class="s-award-bling s-award-bling__silver" title="39 silver badges">39</li> <li class="s-award-bling s-award-bling__bronze" title="54 bronze badges">54</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-5031591"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>38</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>4</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/5031591/query-parameters-with-url-for" class="question-hyperlink">Query parameters with url_for?</a></h3> <div class="excerpt">url_for([:edit, @post]) is working and generating /comments/123/edit. Now I need to add a query parameter, so that instead of /comments/123/edit it is /comments/123/edit?qp=asdf I tried url_for([:edit, @post], :qp => "asdf") but no go. </div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/ruby-on-rails" class="post-tag grid--cell" title="show questions tagged 'ruby-on-rails'" rel="tag">ruby-on-rails</a> <a href="../../questions/tagged/ruby-on-rails-3" class="post-tag grid--cell" title="show questions tagged 'ruby-on-rails-3'" rel="tag">ruby-on-rails-3</a> <a href="../../questions/tagged/query-parameters" class="post-tag grid--cell" title="show questions tagged 'query-parameters'" rel="tag">query-parameters</a> <a href="../../questions/tagged/url-for" class="post-tag grid--cell" title="show questions tagged 'url-for'" rel="tag">url-for</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Feb 17 '11 at 16:19">asked Feb 17 '11 at 16:19</time> <a href="../../users/377920/randomguy" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/377920.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="randomguy" onerror="onImageLoadingError(this);" /> </a> <div class="s-user-card--info"> <a href="../../users/377920/randomguy" class="s-user-card--link">randomguy</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">11,352</li> <li class="s-award-bling s-award-bling__gold" title="14 gold badges">14</li> <li class="s-award-bling s-award-bling__silver" title="65 silver badges">65</li> <li class="s-award-bling s-award-bling__bronze" title="94 bronze badges">94</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-9023488"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>18</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status "> <strong>7</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/9023488/build-error-with-variables-and-url-for-in-flask" class="question-hyperlink">Build error with variables and url_for in Flask</a></h3> <div class="excerpt">Have found one or two people on the interwebs with similar problems, but haven't seen a solution posted anywhere. I'm getting a build error from the code/template below, but can't figure out where the issue is or why it's occurring. It appears that…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/flask" class="post-tag grid--cell" title="show questions tagged 'flask'" rel="tag">flask</a> <a href="../../questions/tagged/werkzeug" class="post-tag grid--cell" title="show questions tagged 'werkzeug'" rel="tag">werkzeug</a> <a href="../../questions/tagged/build-error" class="post-tag grid--cell" title="show questions tagged 'build-error'" rel="tag">build-error</a> <a href="../../questions/tagged/url-for" class="post-tag grid--cell" title="show questions tagged 'url-for'" rel="tag">url-for</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jan 26 '12 at 18:41">asked Jan 26 '12 at 18:41</time> <a href="../../users/1171947/rob" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1171947.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Rob" onerror="onImageLoadingError(this);" /> </a> <div class="s-user-card--info"> <a href="../../users/1171947/rob" class="s-user-card--link">Rob</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">181</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="1 silver badge">1</li> <li class="s-award-bling s-award-bling__bronze" title="4 bronze badge">4</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-26971491"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>18</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/26971491/how-do-i-link-to-images-not-in-static-folder-in-flask" class="question-hyperlink">How do i link to images not in Static folder in flask</a></h3> <div class="excerpt">In flask, how do I serve images that are not in the static folder? I currently save the user uploaded photos on a directory that is outside the flask folder (On openshift, image currently saving in the data folder under app-root/data and the flask…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/static" class="post-tag grid--cell" title="show questions tagged 'static'" rel="tag">static</a> <a href="../../questions/tagged/flask" class="post-tag grid--cell" title="show questions tagged 'flask'" rel="tag">flask</a> <a href="../../questions/tagged/openshift" class="post-tag grid--cell" title="show questions tagged 'openshift'" rel="tag">openshift</a> <a href="../../questions/tagged/url-for" class="post-tag grid--cell" title="show questions tagged 'url-for'" rel="tag">url-for</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Nov 17 '14 at 11:15">asked Nov 17 '14 at 11:15</time> <a href="../../users/786326/shankar-arul" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/786326.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Shankar ARUL" onerror="onImageLoadingError(this);" /> </a> <div class="s-user-card--info"> <a href="../../users/786326/shankar-arul" class="s-user-card--link">Shankar ARUL</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">9,495</li> <li class="s-award-bling s-award-bling__gold" title="8 gold badges">8</li> <li class="s-award-bling s-award-bling__silver" title="59 silver badges">59</li> <li class="s-award-bling s-award-bling__bronze" title="62 bronze badges">62</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-20810630"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>17</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>2</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/20810630/how-to-use-flask-jinja2-url-for-with-multiple-parameters" class="question-hyperlink">how to use Flask Jinja2 url_for with multiple parameters</a></h3> <div class="excerpt">I have a problem while using jinja2 url_for() function. I have a route like this: @app.route('/article/<int:article_id>/<url_title>/', methods=['GET']) def article_page(article_id, url_title): article = Article.query.get(article_id) if…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/flask" class="post-tag grid--cell" title="show questions tagged 'flask'" rel="tag">flask</a> <a href="../../questions/tagged/jinja2" class="post-tag grid--cell" title="show questions tagged 'jinja2'" rel="tag">jinja2</a> <a href="../../questions/tagged/url-for" class="post-tag grid--cell" title="show questions tagged 'url-for'" rel="tag">url-for</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Dec 28 '13 at 03:14">asked Dec 28 '13 at 03:14</time> <a href="../../users/1392295/tiny-lin" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1392295.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Tiny Lin" onerror="onImageLoadingError(this);" /> </a> <div class="s-user-card--info"> <a href="../../users/1392295/tiny-lin" class="s-user-card--link">Tiny Lin</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">208</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="2 silver badge">2</li> <li class="s-award-bling s-award-bling__bronze" title="7 bronze badge">7</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-2257365"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>16</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>5</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/2257365/rails-generate-a-full-url-in-an-actionmailer-view" class="question-hyperlink">Rails: generate a full URL in an ActionMailer view</a></h3> <div class="excerpt">I'm using ActionMailer to send a sign up confirmation email. The email needs to contain a link back to the site to verify the user, but I can't persuade Rails to generate a full URL (including the domain etc). I'm using: <%= url_for :controller =>…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/ruby-on-rails" class="post-tag grid--cell" title="show questions tagged 'ruby-on-rails'" rel="tag">ruby-on-rails</a> <a href="../../questions/tagged/actionmailer" class="post-tag grid--cell" title="show questions tagged 'actionmailer'" rel="tag">actionmailer</a> <a href="../../questions/tagged/host" class="post-tag grid--cell" title="show questions tagged 'host'" rel="tag">host</a> <a href="../../questions/tagged/url-for" class="post-tag grid--cell" title="show questions tagged 'url-for'" rel="tag">url-for</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Feb 13 '10 at 11:49">asked Feb 13 '10 at 11:49</time> <a href="../../users/23008/mike-sutton" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/23008.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Mike Sutton" onerror="onImageLoadingError(this);" /> </a> <div class="s-user-card--info"> <a href="../../users/23008/mike-sutton" class="s-user-card--link">Mike Sutton</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">4,138</li> <li class="s-award-bling s-award-bling__gold" title="4 gold badges">4</li> <li class="s-award-bling s-award-bling__silver" title="25 silver badges">25</li> <li class="s-award-bling s-award-bling__bronze" title="41 bronze badges">41</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-6978603"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>15</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>3</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/6978603/how-to-load-a-javascript-or-css-file-into-a-bottlepy-template" class="question-hyperlink">How to load a javascript or css file into a BottlePy template?</a></h3> <div class="excerpt">I am trying to return a html template with BottlePy. And this works fine. But if I insert a javascript file like this in my tpl-file: <script type="text/javascript" src="js/main.js" charset="utf-8"></script> I get an 404 error. (Failed to load…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/javascript" class="post-tag grid--cell" title="show questions tagged 'javascript'" rel="tag">javascript</a> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/templates" class="post-tag grid--cell" title="show questions tagged 'templates'" rel="tag">templates</a> <a href="../../questions/tagged/bottle" class="post-tag grid--cell" title="show questions tagged 'bottle'" rel="tag">bottle</a> <a href="../../questions/tagged/url-for" class="post-tag grid--cell" title="show questions tagged 'url-for'" rel="tag">url-for</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Aug 08 '11 at 06:43">asked Aug 08 '11 at 06:43</time> <a href="../../users/438743/eltorrero" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/438743.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="eltorrero" onerror="onImageLoadingError(this);" /> </a> <div class="s-user-card--info"> <a href="../../users/438743/eltorrero" class="s-user-card--link">eltorrero</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">307</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="2 silver badge">2</li> <li class="s-award-bling s-award-bling__bronze" title="6 bronze badge">6</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-4404440"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>15</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>4</strong> answers </div> </div> </div> <div class="summary"> <h3><a href="../../questions/4404440/rails-url-for-and-namespaced-models" class="question-hyperlink">Rails url_for and namespaced models</a></h3> <div class="excerpt">In Rails, is it possible to namespace models in modules and still get correct behavior from url_for? For instance, here, url_for works as expected: # app/models/user.rb class User < ActiveRecord::Base end # config/routes.rb resources :users #…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/ruby-on-rails" class="post-tag grid--cell" title="show questions tagged 'ruby-on-rails'" rel="tag">ruby-on-rails</a> <a href="../../questions/tagged/ruby-on-rails-3" class="post-tag grid--cell" title="show questions tagged 'ruby-on-rails-3'" rel="tag">ruby-on-rails-3</a> <a href="../../questions/tagged/namespaces" class="post-tag grid--cell" title="show questions tagged 'namespaces'" rel="tag">namespaces</a> <a href="../../questions/tagged/url-for" class="post-tag grid--cell" title="show questions tagged 'url-for'" rel="tag">url-for</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Dec 10 '10 at 00:05">asked Dec 10 '10 at 00:05</time> <a href="../../users/92049/sebastian" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/92049.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="sebastian" onerror="onImageLoadingError(this);" /> </a> <div class="s-user-card--info"> <a href="../../users/92049/sebastian" class="s-user-card--link">sebastian</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">1,168</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="12 silver badge">12</li> <li class="s-award-bling s-award-bling__bronze" title="20 bronze badge">20</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-23988561"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>12</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/23988561/jinja-variables-within-the-flask-url-for-function" class="question-hyperlink">Jinja variables within the Flask url_for function</a></h3> <div class="excerpt">I have tried multiple different things, but cannot get the URL to appear as /item like I want it to. I know that everything else is functioning correctly because if I simply replace {{item}} with a string, it works fine. Am I missing something…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/variables" class="post-tag grid--cell" title="show questions tagged 'variables'" rel="tag">variables</a> <a href="../../questions/tagged/flask" class="post-tag grid--cell" title="show questions tagged 'flask'" rel="tag">flask</a> <a href="../../questions/tagged/convention" class="post-tag grid--cell" title="show questions tagged 'convention'" rel="tag">convention</a> <a href="../../questions/tagged/jinja2" class="post-tag grid--cell" title="show questions tagged 'jinja2'" rel="tag">jinja2</a> <a href="../../questions/tagged/url-for" class="post-tag grid--cell" title="show questions tagged 'url-for'" rel="tag">url-for</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jun 02 '14 at 06:36">asked Jun 02 '14 at 06:36</time> <a href="../../users/2390195/excuse-my-stupidity" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/2390195.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Excuse.my.stupidity" onerror="onImageLoadingError(this);" /> </a> <div class="s-user-card--info"> <a href="../../users/2390195/excuse-my-stupidity" class="s-user-card--link">Excuse.my.stupidity</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">241</li> <li class="s-award-bling s-award-bling__gold" title="1 gold badge">1</li> <li class="s-award-bling s-award-bling__silver" title="2 silver badge">2</li> <li class="s-award-bling s-award-bling__bronze" title="7 bronze badge">7</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-15044094"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>11</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/15044094/flask-static-files-in-subdirectories" class="question-hyperlink">Flask: Static files in subdirectories</a></h3> <div class="excerpt">In my flask template file I include a css file (I ommited the boilerplate) like this: url_for('static', filename='css/bootstrap.css') This renders to /static/css/bootstrap.css which means (because of leading slash) it is interpreted as…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/flask" class="post-tag grid--cell" title="show questions tagged 'flask'" rel="tag">flask</a> <a href="../../questions/tagged/fastcgi" class="post-tag grid--cell" title="show questions tagged 'fastcgi'" rel="tag">fastcgi</a> <a href="../../questions/tagged/url-for" class="post-tag grid--cell" title="show questions tagged 'url-for'" rel="tag">url-for</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Feb 23 '13 at 18:34">asked Feb 23 '13 at 18:34</time> <a href="../../users/488265/jonas-groger" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/488265.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Jonas Gröger" onerror="onImageLoadingError(this);" /> </a> <div class="s-user-card--info"> <a href="../../users/488265/jonas-groger" class="s-user-card--link">Jonas Gröger</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">1,347</li> <li class="s-award-bling s-award-bling__gold" title="2 gold badges">2</li> <li class="s-award-bling s-award-bling__silver" title="19 silver badges">19</li> <li class="s-award-bling s-award-bling__bronze" title="32 bronze badges">32</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-41250560"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>10</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status answered-accepted"> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/41250560/flask-where-to-put-static-javascript-files-in-templates" class="question-hyperlink">Flask: where to put static javascript files in templates</a></h3> <div class="excerpt">I'm developing a flask app with the following folder structure: |-->flask_app.py |-->static |-->css |-->bootstrap.min.css |-->styles.css |-->js |-->jquery-3.1.1.min.js …</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/css" class="post-tag grid--cell" title="show questions tagged 'css'" rel="tag">css</a> <a href="../../questions/tagged/flask" class="post-tag grid--cell" title="show questions tagged 'flask'" rel="tag">flask</a> <a href="../../questions/tagged/static" class="post-tag grid--cell" title="show questions tagged 'static'" rel="tag">static</a> <a href="../../questions/tagged/url-for" class="post-tag grid--cell" title="show questions tagged 'url-for'" rel="tag">url-for</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Dec 20 '16 at 20:15">asked Dec 20 '16 at 20:15</time> <a href="../../users/6611672/johnny-metz" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/6611672.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Johnny Metz" onerror="onImageLoadingError(this);" /> </a> <div class="s-user-card--info"> <a href="../../users/6611672/johnny-metz" class="s-user-card--link">Johnny Metz</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">3,186</li> <li class="s-award-bling s-award-bling__gold" title="6 gold badges">6</li> <li class="s-award-bling s-award-bling__silver" title="40 silver badges">40</li> <li class="s-award-bling s-award-bling__bronze" title="97 bronze badges">97</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="mln24"> <div class="question-summary" id="question-summary-48825486"> <div class="statscontainer"> <div class="stats"> <div class="vote"> <div class="votes"> <span class="vote-count-post"><strong>7</strong></span> <div class="viewcount">votes</div> </div> </div> <div class="status "> <strong>1</strong> answer </div> </div> </div> <div class="summary"> <h3><a href="../../questions/48825486/jinja-ignores-html-comments" class="question-hyperlink">Jinja ignores HTML comments</a></h3> <div class="excerpt">Not a question per sae but an observation others may find helpful. I have had issues with 'werkzeug.routing.BuildError: Could not build url for endpoint ... ' errors when using Flask to build a website. As part of my development I had created a menu…</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/python" class="post-tag grid--cell" title="show questions tagged 'python'" rel="tag">python</a> <a href="../../questions/tagged/html" class="post-tag grid--cell" title="show questions tagged 'html'" rel="tag">html</a> <a href="../../questions/tagged/flask" class="post-tag grid--cell" title="show questions tagged 'flask'" rel="tag">flask</a> <a href="../../questions/tagged/comments" class="post-tag grid--cell" title="show questions tagged 'comments'" rel="tag">comments</a> <a href="../../questions/tagged/url-for" class="post-tag grid--cell" title="show questions tagged 'url-for'" rel="tag">url-for</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Feb 16 '18 at 11:09">asked Feb 16 '18 at 11:09</time> <a href="../../users/8899437/mhwalmsley" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/8899437.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="mhwalmsley" onerror="onImageLoadingError(this);" /> </a> <div class="s-user-card--info"> <a href="../../users/8899437/mhwalmsley" class="s-user-card--link">mhwalmsley</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">71</li> <li class="s-award-bling s-award-bling__silver" title="1 silver badges">1</li> <li class="s-award-bling s-award-bling__bronze" title="3 bronze badges">3</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <div class="s-pagination--item is-selected">1</div> <a class="s-pagination--item" href="../../questions/tagged/url-for_page=2" rel="" title="Go to page 2">2</a> <a class="s-pagination--item" href="../../questions/tagged/url-for_page=3" rel="" title="Go to page 3">3</a> <div class="s-pagination--item s-pagination--item__clear">…</div> <a class="s-pagination--item" href="../../questions/tagged/url-for_page=12" rel="" title="Go to page 12">12</a> <a class="s-pagination--item" href="../../questions/tagged/url-for_page=13" rel="" title="Go to page 13">13</a> <a class="s-pagination--item" href="../../questions/tagged/url-for_page=2" rel="next" title="Go to page 2"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script> /* replace <time class="fromnow" /> with human delta between `datetime` attr and now */ document.addEventListener('DOMContentLoaded', function(){ var time_elements = document.querySelectorAll("time.fromnow"); for (var i=0; i<time_elements.length; i++) { time_elements[i].innerHTML = moment(time_elements[i].getAttribute("datetime")).fromNow(); } }); </script> </body> </html>