S
S
systemiv2013-01-24 21:59:18
Flask
systemiv, 2013-01-24 21:59:18

Get file content for further processing?

Hello!
Started learning flask microframework in python.
The problem arose when uploading a file, I found only information on how to save it to a directory:

f = request.files['file']<br>
f.save('data/structure.txt')<br>

But how to read it, no.
As a consequence, there are two options:
1. Is it possible to get data from a file without saving?
2. Or do you need to save, and only then read it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
akral, 2013-01-24
@systemiv

Have you tried just read?

f.read()

I
igrishaev, 2013-01-25
@igrishaev

On the subject: the flask-uploads extension makes it very easy to work with uploaded files - it checks extensions, size, makes names safe, automatically puts them in the right directories.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question