Python Forum
Flask, Display a picture outisde the static
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Flask, Display a picture outisde the static
#1
Hi everyone,

I have a html page under template\about\index.html

Is it possible to display an image who is located in the same path -> template\about\img.jpg ??

Because I have an error ->


template\about\index.html is display on the "/" it's on purpose.
I created app.add_url_rule('/about', 'about', about) to try to solve the access problem but it's not helping.

from flask import Flask, render_template

app = Flask(__name__)


def index():
   return render_template("about/index.html")

def about():
   pass


app.add_url_rule('/', 'index', index)
app.add_url_rule('/about', 'about', about)
index.html
<!DOCTYPE html>
<html lang="en">

<head>
  <title>About</title>
</head>

<body>
  This is our base template :) <BR>
  

<img src="about/Joker.png">


</body>

</html>
When I point my browser to http://192.168.80.11:5000/about/img.jpg
I get a 404 error (not found) :/
[Image: NfRQr9R.jpg]
Reply


Messages In This Thread
Flask, Display a picture outisde the static - by SpongeB0B - Aug-06-2020, 05:40 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question [Solved] Private static files SpongeB0B 1 1,165 Jul-16-2022, 05:36 AM
Last Post: SpongeB0B
  SHow image in a static link of Django pycada 3 2,660 Mar-04-2020, 01:50 AM
Last Post: pycada
  display multiple sensors on webpage python flask jinja pascale 6 5,431 Jan-29-2019, 10:10 AM
Last Post: pascale
  flask requests display data from api on webpage with javacript pascale 0 2,843 Oct-25-2018, 08:30 PM
Last Post: pascale
  Django loading static files Dutchpy 7 24,231 Oct-13-2017, 10:25 AM
Last Post: hbknjr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020