Skip to content

Tag: flask

Not able to parse a .csv file uploaded using Flask

I am trying to upload a CSV file, work on it to produce results, and write back (download) a new CSV file containing the result. I am very new to Flask and I am not able to get a “proper” csv.reader object to iterate and work upon. Here is the code so far, The terminal output being Whereas the fil…

Get the value of a checkbox in Flask

I want to get the value of a checkbox in Flask. I’ve read a similar post and tried to use the output of request.form.getlist(‘match’) and since it’s a list I use [0], but it seems I’m doing something wrong. Is this the correct way to get the output or is there a better way? Answe…

Show the SQL generated by Flask-SQLAlchemy

I want to get the SQL issued by Flask-SQLAlchemy queries. In Django, I can print the query attribute to get SQL. How can I get something similar in Flask? Answer Flask-SQLAlchemy records debugging information about all queries during a request. You can get the information with get_debug_queries(). Flask-Debug…

How to run a flask application?

I want to know the correct way to start a flask application. The docs show two different commands: and produce the same result and run the application correctly. What is the difference between the two and which should be used to run a Flask application? Answer The flask command is a CLI for interacting with F…

flask socketio CORS

I’ve been trying to send data from flask over socket io. I need to access this data from a different origin, but it is giving a CORS error. I have tried using all kinds of cross origin stuff and none of it has worked. Can somebody help with this. The view that should be called thought socket io: Running…

How to send requests with JSON in unit tests

I have code within a Flask application that uses JSONs in the request, and I can get the JSON object like so: This has been working fine, however I am trying to create unit tests using Python’s unittest module and I’m having difficulty finding a way to send a JSON with the request. This gives me: …