Linked Questions

0 votes
0 answers
195 views

Flask: how to return an image to browser? [duplicate]

Well, I'm learning Flask. And now I want to show an image to browser like 127.0.0.1/test.png. But I can't find how to do that in document, and I've tried this but it doesn't work: from flask import ...
Remi Guan's user avatar
  • 21.9k
2 votes
0 answers
156 views

Flask + Leaflet - How to use custom local tiles ? (GET 404 Not Found) [duplicate]

I am trying to create a Leaflet map with custom tiles on top of OSM base layer (from Leaflet.js), using Flask. I generated a set of tiles from geo-referenced GeoTIFF images, and I first visualized ...
jegertor's user avatar
817 votes
24 answers
1.0m views

How to serve static files in Flask

So this is embarrassing. I've got an application that I threw together in Flask and for now it is just serving up a single static HTML page with some links to CSS and JS. And I can't find where in the ...
hughdbrown's user avatar
  • 48.4k
97 votes
4 answers
139k views

Flask to return image stored in database

My images are stored in a MongoDB, and I'd like to return them to the client, here is how the code is like: @app.route("/images/<int:pid>.jpg") def getImage(pid): # get image binary from ...
wong2's user avatar
  • 35k
39 votes
1 answer
23k views

What is the difference between Flask's send_file and send_from_directory?

It is still not clear for me when to use send_file and when send_from_directory. I have a file in a folder protected. I can access the file from both methods. So perhaps someone has an example that ...
Alex Fillips's user avatar
6 votes
1 answer
13k views

How to send an image directly from flask server to html?

I am new to flask and am trying to make an app such an image is taken by the html and js from the webcam and then it is sent to the server with ajax request. I got this part. Then some processing is ...
Shantanu Shinde's user avatar
2 votes
1 answer
9k views

How to return image as part of response from a GET request in Flask?

I have a basic Python Flask API set up right not that takes an ID as a parameter for a GET request. Inside the get request logic, I am doing a get request on another resource to retrieve an image ...
Ryan Fasching's user avatar
2 votes
1 answer
10k views

How to display images from folder in Python html and flask

I am very new to python and Flask. I have a folder with a list of jpeg images. I have to display them in my demo application with flask as below, My app.py : @app.route("/") def home(): return ...
Uma's user avatar
  • 29
2 votes
1 answer
3k views

Why can't flask find this file?

I am trying to return a jpg file from a get request in Flask using this answer as a guide How to return images in flask response? I have this code running in my root directory (off a tornado server): ...
bernie2436's user avatar
  • 23.3k
1 vote
0 answers
2k views

Relative path in Flask is not picking up a file [duplicate]

I am building my first Flask application on local machine and have issues with path to images that I use in my HTML. My folder structure is very simple: -templates folder -assets folder ...
Dmitry Khavanskiy's user avatar
2 votes
1 answer
864 views

Deploying a Machine Learning model as REST API using Flask. Error: RuntimeError: Working outside of request context

I've developed a classifier for test classification. and trying to access it using REST API. Here is the code: clf_model = joblib.load('MNB_Clf.pkl','r') app = Flask(__name__) @app.route('/...
pavan subhash's user avatar