Categories
Python Answers

How to read file data without saving it in Python Flask?

Spread the love

Sometimes, we want to read file data without saving it in Python Flask.

In this article, we’ll look at how to read file data without saving it in Python Flask.

How to read file data without saving it in Python Flask?

To read file data without saving it in Python Flask, we can access the file from request.files.

For instance, we write

@app.route('/upload/', methods=['POST'])
def upload():
    if request.method == 'POST':
        file = request.files["file"]                    
        if file:
            df = pd.read_excel(files_excel["file"])

to get the file with request.files["file"]

Then we can do what we want with the file without saving it.

Conclusion

To read file data without saving it in Python Flask, we can access the file from request.files.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *