I have a flask application where I need to render an image created by Pygal (a visualization library).So I plan to give users access to this created image at an endpoint /viz
app = Flask(__name__)@app.route("/viz")
def viz():img_url = '/home/souvik/PycharmProjects/ServiceHandler/static/histo_visual.svg'return render_template('app.html', image_url=img_url)
Below is the app.html file
<html>
<head><title> Metric Visualization</title>
</head>
<body><div><p>Bar Chart</p><object type="image/svg+xml" data="{{image_url}}"></object></div>
</body>
</html>
Here is my project structure
As you can see the file histo_visual.svg does exists in the static folder.So when I run the program and try to access the /viz
endpoint, I get the below error
127.0.0.1 - - [10/Apr/2018 15:08:59] "GET /viz HTTP/1.1" 200 -
127.0.0.1 - - [10/Apr/2018 15:08:59] "GET /home/souvik/PycharmProjects/ServiceHandler/static/ HTTP/1.1" 404 -
Below is the page displayed
Why does it give 404
not found error when the file exists?I have even gone to the directory and run the file through a browser and it shows me the expected visualization.Then what is going wrong?