Skip to content
Advertisement

How to open and process .rtf files in Flask

I am trying to send a request including a rtf file and process it in Flask.

In my python script, I used the striprtf lib to read this file and then process it.

JavaScript

Now I want to wrap this script into flask. I got error said: TypeError: expected string or bytes-like object. How can I read this rtf file in the flask?

JavaScript

Advertisement

Answer

Try the read method of file, which is a werkzeug.datastructures.FileStorage object.

You’ll then need to decode this to provide rtf_to_text with the string it expects.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement