url-for

Stylesheet url_for code for image in a parallel folder

Stylesheet url_for code for image in a parallel folder Question: I am attempting to build a website using Flask. I am using Python 3.9 I have the following directory tree: environment/ main.py app.yaml requirements.txt Templates/ base.html #base template index.html #extends base.html Static/ css/ main.css images/ favicon.ico bckgrnd.jpg fonts/ Carolingian.ttf Latin.ttf Here is the code in …

Total answers: 1

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

Where do I define the domain to be used by url_for() in Flask? Question: 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’)? Asked …

Total answers: 1

Creating link to an url of Flask app in jinja2 template

Creating link to an url of Flask app in jinja2 template Question: In my Flask app, I have a view which displays a post @post_blueprint.route(‘/post/<int:year>/<int:month>/<title>’) def get_post(year,month,title): # My code To display the last 10 entries, I have following view: @post_blueprint.route(‘/posts/’) def get_all_posts(): # My code return render_template(‘p.html’,posts=posts) Now when I display the last 10 …

Total answers: 1

Flask url_for URLs in Javascript

Flask url_for URLs in Javascript Question: 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 template engine. What basically …

Total answers: 9