Questions tagged [flask]

Flask is a lightweight framework for developing web applications using Python.

0
votes
0answers
10 views

Get Current Web Hyperlink in Flask [duplicate]

I have a flask app that has searchable content. When the users enter a search term, they have the choice to choose from many results that each have a unique hyperlink. These results have strange ...
-1
votes
0answers
20 views

trying to use flask for simple web form, it never updates mariadb

I am try to create a simple webform that just collect name and email and stores it in a mariadb. I have created the db and the table and the user has the appropriate permissions. Here is the Python3 ...
0
votes
0answers
11 views

Errorhandler is not called for custom exception

I have the following error handlers: @api.errorhandler(DatabaseException) def handle_database_exception(database_error): return database_error.query_error, 400 @api.errorhandler(...
0
votes
1answer
15 views

Register global request handler for all blueprints in Flask [duplicate]

I'm trying to register before_request and after_request handlers for all routes (in all blueprints) in Flask. It's easy to register for a single blueprint: main = flask.Blueprint('main', __name__) @...
0
votes
0answers
23 views

Self-Signed SSL Certificate Changes Upon Retrieval

I have a very simple flask HTTPS server running using a self-signed certificate on a google compute instance. Here is the code for the server: from flask import Flask app = Flask(__name__) with open(...
0
votes
0answers
11 views

Reading Flask configuration values outside of request context (such as a separate class) [duplicate]

I have an Flask application that reads in config values using app.config.from_object, to be accessed with app.config[key]. I have a class that manages connection to a cloud service, which requires ...
-1
votes
0answers
19 views

'The address wasn’t understood' error if the method is post [duplicate]

I have a flask server with a login route. My idea is that if I make a GET request, the template logs in, but when I submit the form, the template is supposed to check the username and password and ...
0
votes
1answer
23 views

convert mysql query return type

I am developing a webapp for a school project in Flask. I am very new to python and flask. In function "get_absence" i am executing a mysql query and i get result. (The query is working in mysql ...
0
votes
0answers
14 views

Python Multi-Threading Process Won't Terminate

I've currently got a Flask server running with SocketIO and I want it so a python function is constantly running until a Socket message is received, at which point I want to stop the first function ...
0
votes
0answers
9 views

How to get the json for Unittesting [duplicate]

I am creating a test(using unittest) for a flask API that I created. I am stuck at returning the json so that I can test it. I keep getting this error. I haven't gotten a good explanation as to what ...
0
votes
0answers
20 views

Can I send requests between two endpoints? [duplicate]

Let's say I have those 2 view functions, vf1 and vf2, and I want them to communicate using the requests lib something like: @app.route('/vf1') def vf1(): r = requests.get('http://localhost:5000/...
0
votes
1answer
11 views

Pass file path as parameter in Flask app.route() [duplicate]

Here is my code. I'm trying to take the file path in as a parameter but the "/" in the path between directories is making the method treat the directories as separate parameters. from flask import ...
0
votes
0answers
7 views

How to run my webscraper with a Flask REST API without waiting for it to finish before returning a response? [duplicate]

I have a RESTFUL API that I built with Flask which runs a webscraper to download files. I want to host it on a linux EC2 instance and serve it using NGINX and Gunicorn. I have been testing my API ...
-1
votes
0answers
11 views

Heroku - Error making a POST request to Flask server [duplicate]

I have a created a basic server using Flask and I am having an issue deploying it on Heroku. I have attached the code below. app.py: app = Flask(__name__) CORS(app) port = int(os.environ.get('PORT', ...
0
votes
1answer
21 views

How to embed a DataTable widget in a Python Flask Web App

Apologies if this question is answered elsewhere on StackOverflow, I did my best to search for an answer before posting this question. I am working to create a Flask-based web app using Bokeh for ...
0
votes
1answer
22 views

Save and send large numpy arrays with Flask

I am looking for the best way to send large Numpy arrays (composed mainly of images) via Flask. For now, I am now doing something like this: Server side: np.save(matrix_path, my_array) return ...
-1
votes
2answers
32 views

Securely send passwords from login form in Flask

I have a website with a simple login function using sessions. I thought it was secure because I was hashing and salting the passwords, but I have realised that what's actually (probably) happening is ...
0
votes
1answer
27 views

How to execute script from container within another container?

I have a contanarized flask app with external db, that logs users on other site using selenium. Everything work perfectly in localhost. I want to deploy this app using containers and found selenium ...
0
votes
0answers
6 views

Flask OIDC user login is true but token is None

I am using Flask-OIDC library to perform user authentication to external service. When the user login for the first time the ODIC library works well. I can see the user information and the Bearer ...
1
vote
1answer
22 views

Flask loads the same index.js file when running from different project

I've tried very hard, but I'm stuck for hours and hours on end — excuse the newb question. I'm encountering the following problem when trying to run a flask app locally: I've used URL_FOR and ...
-1
votes
1answer
17 views

How to get rid of global variables in a flask server code? [duplicate]

While writing a flask server I find myself in a situation similar to this: from flask import Flask, jsonify app = Flask(__name__) x = 0 @app.route('/method_a', methods=['GET']) def method_a(): ...
1
vote
1answer
13 views

How to wrap REST API response with Wrapper object in Python Flask

While building REST API with flask-restful I'm getting unwanted json array in my response { "data": [ { "email": "sam@test.com", "id": null, "name": "...
-1
votes
1answer
15 views

Accessing a variable from a module [duplicate]

I have to make a DIY robot. In order to find out orientation of robot I am using my smartphone and PhonePi app. The app is based on Flask server. The code for getting orientation is given below and I ...
-1
votes
2answers
23 views

Caching or something else? Page not updating with Flask / nginx [duplicate]

I have set up a website that uses Flask, nginx and uWSGI. The website needs to always show the most up to date information. I have been testing that by changing the theme of my website. I made this ...
0
votes
1answer
14 views

Jinja2 access a list of dict in javascript [duplicate]

Hey all any idea how to access a list of dict ? In Flask: users = [{ 'username': 'john', 'city': 'Toronto' }, { 'username': 'James', 'city': 'Montreal' }] return render_template('...
-1
votes
0answers
14 views

Python: Flask getting error when importing module from a python file [duplicate]

I'm trying to create an OpenCV API using Flask. In my app.py file: from flask import Flask, jsonify app = Flask(__name__) @app.route('/api/lot', methods=['GET']) def get_lot(): return jsonify(...
0
votes
0answers
16 views

SQLAlchemy retrieve html from MySQL [duplicate]

I have some HTML stored in a MySQL(INNODB) table. Flask-SQLAlchemy can access the table and retrieve the HTML as a Text field. However when I output the result into a template, all of the '<' &...
0
votes
0answers
16 views

implementing flask_jwt_extended with templates rendering

Again fighting trying to make my first flask application, this time, (after I created every I need and all works smoothly) I'm trying to protect some endpoints with flask_jwt_extended, but I can't ...
-1
votes
3answers
41 views

Jinja2 If ignores boolean value

I have a Jinja2 template where a variable that resolves as a boolean False is being ignored in an {% if %} statement. The relevant chunk of the template looks like {% if user.can_manage_techniques %}...
0
votes
0answers
30 views

Correct use of sqlalchemy sesion with Flask

I am trying to use sqlalchemy with flask(without the flask-sqlalchemy extension). I am struggling with how to integrate the session object of sqlalchemy with flask. I have seen several approaches: 1)...
-1
votes
0answers
20 views

Interfacing my machine learning code (through a REST API) to my app by using Volley [duplicate]

I am trying to learn how can I deploy my machine learning code that uses random forest classifier on iris data set to classify flowers. But I want the data for classification to be fed from my android ...
-2
votes
0answers
17 views

How can we put authentication on the REST API's written in Flask with Python? [on hold]

I have to apply authentication over the Flask REST API with Python to make them access securely by the genuine user. What code and config settings I have to do in Flask to achieve it?
0
votes
1answer
16 views

Flask Upload Image to S3 without saving it to local file system

I need to upload a a user submitted photo to an s3 bucket. However I keep getting the following error: TypeError: expected str, bytes or os.PathLike object, not FileStorage How am I able to store ...
-2
votes
0answers
12 views

Flask-socketio for real time communication [on hold]

Is flask-socketio the best option to develop a chat app using python? if not could anyone suggest me other libraries I could use to implement a real time communication in my chat app?
0
votes
0answers
20 views

save pil or cv2 based image inside flask server and then serving that url for image rendering in the front end

I am updating an image sent through post method using cv2 in the flask backend. Then when I am trying to save that image using cv2.imwrite() to a path inside the flask server and then send that path ...
0
votes
1answer
14 views

Jinja Flask issue: Uncaught SyntaxError: Unexpected token { in JSON at position 1 at JSON.parse

Hi I've got an issue passing a simple variable from Flask app to javascript. My python looks as follows: @app.route('/') def loadInitialData(): data={"grade":"0"} return render_template('...
0
votes
0answers
22 views

Sending files through XMLHttpRequest formdata. Can send file name but not file? [duplicate]

I am trying to upload a file to a website using Flask, FormData and an XMLHttpRequest, however I'm having some trouble getting it to work properly. (Relevant) HTML code: <form onsubmit="...
0
votes
0answers
15 views

Run Flask and Apache2 on the same port to avoid CORS

I am running a Debian 9 server with Apache2 and Flask. Flask is running on port 5000 and Apache2 is running on port 80. Frontend I am making AJAX calls, but I am getting CORS as the browser blocks ...
1
vote
0answers
16 views

Session variable not available with ajax request in edge?

I've tried to simply the example below. Basically what I've found is that on a regular page request, like the one for the index or /login, session variables are available. But for my ajax call from my ...
0
votes
0answers
21 views

Getting data from inputs dynamically added to a FieldList

I'm attempting to retrieve data from a list of inputs dynamically added to a FieldList. I am using javascript in order to add the input elements. But when I try to use request to get the entered ...
0
votes
0answers
9 views

Ajax Request literally taking pre-rendered value in Flask [duplicate]

I have setup a success Ajax call, however my index value is literally just getting from Jinja2 template literal string on my Flask server. So the values I am getting back from my POST request, is a ...
0
votes
0answers
19 views

Flask how many backend instances are running when served with uwsgi [duplicate]

My settings: Python 3.7.1 Flask 1.0.2 linux Anaconda3 Problem description: I am running a flask app, and the backend loads a few hundred MB data to a global variable data and it provide ...
0
votes
0answers
23 views

Is it a security threat to use Flask sessions to authenticate users? [duplicate]

I'm using Flask session to check whether a user has correctly entered a password. When a user enters a password right, I set session["authenticated"] = True. I have a login page that looks like the ...
-2
votes
0answers
14 views

400 bad request flask when storing file [on hold]

I am want to upload a file from a html form to a database using flask and flask-alchemy but I get this error : werkzeug.exceptions.HTTPException.wrap..newcls: 400 Bad Request: KeyError: 'fileContent' ...
-1
votes
1answer
23 views

json vs jinja2 templates rendering

I'm currently sending data from my flask application to my HTML pages as dicts or list and I use templates rendering to display the values like {{data[0]}}, and I'm wondering is it a bad practice? ...
0
votes
0answers
8 views

How to query Flask-SQLAlchemy many-to-many relationship, so that a list of full objects is properly marshaled by Flask-RESTPlus?

Let's say I have a following many-to-many relationship: model_a_to_model_b = db.Table( 'model_a_to_model_b', db.Column('model_a_id', db.Integer, db.ForeignKey('model_a.id'), primary_key=True)...
0
votes
1answer
15 views

Flask: request method not picking up the datetime value from web form via AJAX

I am creating a web form where one two fields are of datetime data types. Then I am passing this form data to server via AJAX. Below is the code JQuery snippet. $(document).ready(function(){ $('#...
0
votes
0answers
18 views

How do I save data on Flask shutdown [duplicate]

I have a Flask app that receives post data, manipulates the data, and sends to AWS storage. The call to AWS is pretty time consuming, so I batch the data in a global object that sends the data to the ...
0
votes
2answers
28 views

Why am I getting a response from the wrong API endpoint?

I am following this tutorial initially I was trying to get a response using postman with the url ec2-x-x-xxx-xx.eu-west-2.compute.amazonaws.com/:8080 but it would not return a response, so then I ...
0
votes
1answer
21 views

how do I read a text file into my .py file with Flask and then get a line-by-line array? [duplicate]

Please see here for my command line output: (https://i.stack.imgur.com/l8Qbl.jpg) It says the file /static/poemInput.txt doesn't exist.. but as you can see, it clearly exists when I execute ls static....

http://mssss.yulina-kosm.ru