I’m using Flask Uploads for an upload form in my Flask application. However, whenever I try to save a file I get this error: It seems like uploads doesn’t have the necessary permissions to save files? Here’s the configuration I’m using for flask-uploads: Also, here’s how I save the actual file: The error is caused by the save line. Any
Tag: flask
Flask-Babel do not translate anything in a web project
Description of my usage: This is my project structure(basically base on Flask Web Development): Configuration in /babel.cfg and /app/__init__.py babel.cfg: app/__init__.py: Then I follow the Flask-Babel document Run $ pybabel extract -F babel.cfg -o messages.pot . Run $ pybabel extract -F babel.cfg -k lazy_gettext -o messages.pot . They do have found all the gettexts and lazy_gettexts. Run $ pybabel init
Flask cannot import enumerate? UndefinedError: ‘enumerate’ is undefined
I just write this code in a HTML page. So, Flask do not support the enumerate? Answer As Or Duan says, Jinja2 has its own language. Looks like Python but it’s not Python. So the Python enumerate built-in function is not part of Jinja2 template engine. There are, however, some alternatives you can use: If you want to enumerate the
How to send a dynamically generate zipfile to the client
I am looking for a way to send a zipfile to the client that is generated from a requests response. In this example, I send a JSON string to a URL which returns a zip file of the converted JSON string. But my zip file is empty and the error returned by flask is Answer You should return the file
Object Oriented Python with Flask Server?
I’m using Flask to expose some data-crunching code as a web service. I’d like to have some class variables that my Flask functions can access. Let me walk you through where I’m stuck: When I run getSomeData() outside of Flask, it works fine. But, when I run this with Flask, I get 500 internal server error. There’s no magic here,
Flask-RESTful custom routes other than GET,PUT,POST,DELETE
In Flask-RESTful we add an api route like the below so that GET /api/kitty –> to CuteKitty.get() method; like this for all HTTP verbs Lets say that I need to provide my api consumers with a cute api like How can i achive the above routing with api.add_resource Like wise how to add route like /api/kitty/<int:kitty_id>/habits –> CuteKitty.habits(kitty_id) Answer Flask-RESTful
Can’t access Postgres DB on Heroku app
I have a Python 2.7 / Flask app running on Heroku that scrapes data and I now want to store that information in a database. I’ve tried to follow tutorials like this one and apply this to my case but I can’t get it to work. I have created & promoted my postgres database successfully on heroku. I am fairly
Print raw HTTP request in Flask or WSGI
I am debugging a microcontroller I’ve built which is writing raw HTTP requests line by line. I am using Flask for my backend and I would like to see the entire request as it appears in this format: I know Flask is based on WSGI. Is there anyway to get this to work with Flask? Answer With flask you have
Can Flask support an optional parameter in a POST request?
In the application, the user has a choice to upload a picture or not. But seems to cause the page to stop loading the request if no such file exists. Is there any way to make this optional? Answer You are using syntax that throws an exception if the key is not present. Use .get() instead: This returns None if
What are Flask Blueprints, exactly?
I have read the official Flask documentation on Blueprints and even one or two blog posts on using them. I’ve even used them in my web app, but I don’t completely understand what they are or how they fit into my app as a whole. How is it similar to an instance of my app but not quite? The documentation