55,185 questions
Best practices
0
votes
4
replies
81
views
Python: two Flask projects under the same HTTP Port
I have 2 separate projects running on the same Linux server. Both projects based on Flask. Due to infrastructure restrictions I'm able to use only one HTTP Port on the server.
I would like to route ...
0
votes
0
answers
42
views
Is there any way to fix type errors when overriding make_response?
I don't want to inherit from Response I want to use a pydantic model. I am doing this:
class AppResponse(BaseModel):
somefield: str
otherfield: int
class FlaskApp(Flask):
# Tried doing ...
0
votes
1
answer
27
views
Quart (Flask) file uploaded removed right after request completed
I'm using Quart (Flask fork) and I have a view which handles ".bin" file upload (100MB).
But on file.save(path) call I can see the file appears in destination folder for moment and ...
1
vote
0
answers
38
views
Locust POST Request with .xlsx File to Flask Endpoint Returns a 503 Error
I am testing my Python Flask app using Locust to load-test a POST request with an .xlsx file attachment. However, I consistently encounter a 503 Service Unavailable error.
This issue ONLY occurs when ...
0
votes
0
answers
56
views
WebClient sending an empty multipart request to Flask service
I have a problem with sending multipart/form-data requests from my Java service (using WebClient but same history with RestTemplate) to Flask service. It seems like a sent body is just empty as I get ...
0
votes
0
answers
52
views
MongoDB Atlas Timeout After Deployment Update — "ReplicaSetNoPrimary"
I updated my backend deployment (Flask app) with a new feature not related to database logic, and suddenly MongoDB Atlas connections no longer work. Before the update, everything was fine.
Local ...
0
votes
0
answers
30
views
flask-scoketio: emitting from an external process without a message queue
I am developing a project using flask, flask-socketio, and the Multiprocessing python libraries.
My site runs on localhost (127.0.0.1:5000).
The goal is to update the html template every second from ...
0
votes
0
answers
31
views
I my flask app data store as json file when we refresh the page then all admin page data will disappear but store in the database fix this problem?
Frontend not connected to backend saving API
The “Save Application” buttons (like saveRegularApplication()) only push data into a JS array applications[] — they never send it to the backend /save-...
1
vote
0
answers
76
views
Memory Leak in Flask-SQLAlchemy 2.5.1 with SQLALCHEMY_RECORD_QUERIES - sqlalchemy_queries List Growing Indefinitely
Environment
Flask: 2.0.3
Flask-SQLAlchemy: 2.5.1
SQLAlchemy: 1.4.41
Deployment: Gunicorn with thread workers
Traffic: ~4 RPS in production
Observed Issue: Memory grows from 35-40% to 90% over 30 ...
0
votes
1
answer
91
views
javascript fetch and redirect through flask view not working as expected
In the html intro to a web app for a scientific study, data is collected through forms.
I added a javascript function that submits the data via the fetch API:
fetch('/prepare/', {
"method":...
840
votes
24
answers
1.1m
views
How to serve static files in Flask
So this is embarrassing. I've got an application that I threw together in Flask and for now it is just serving up a single static HTML page with some links to CSS and JS. And I can't find where in the ...
0
votes
1
answer
67
views
Does flask dev server normalize paths?
I was playing a CTF which was about path traversal. The server code was like below:
import flask
import os
app = flask.Flask(__name__)
@app.route("/docs/<path:path>", methods=["...
1
vote
1
answer
72
views
Gunicorn with worker 1 not able to call local API
I have flask app, which we are running using gunicorn.
App structure.
% tree your_flask_app
your_flask_app
├── __init__.py
├── app.py
└── routes
├── __init__.py
├── data.py
└── shared.py
...
1
vote
1
answer
77
views
Flask not redirecting to Dashboard after login
I am using flask as the backend for my project. I created a login form with html and a route in flask. I am using Mysql as the database. When I fill in the form and click log in, the page is just ...
203
votes
6
answers
215k
views
Why did Flask start failing with "ImportError: cannot import name 'url_quote' from 'werkzeug.urls'"?
Environment:
Python 3.10.11
Flask==2.2.2
I run my Flask backend code in docker container, with BASE Image:
FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime
But when I run the pytest with version ...
108
votes
16
answers
305k
views
Import could not be resolved/could not be resolved from source Pylance in VS Code using Python 3.9.2 on Windows 10
My Flask App server is running but I have three imports that cannot be resolved.
I have tried:
reinstalling the imports individually
reinstalling requirements.txt
I configured VSCode Workspace with ...
0
votes
0
answers
70
views
How to load environment variables in PythonAnywhere?
I have just finished working on a Flask web application that is using openai SDK.
Locally everything works smoothly, but after uploading the project on PythonAnywhere, the environment variables from ....
1
vote
1
answer
60
views
Flask SQL model missing one positional argument
from flask import (Flask, render_template)
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://user:password@localhost/database'
db = ...
0
votes
1
answer
68
views
Will file logging race conditions in multi-process Flask app crash the Python script?
I have a Flask application running on Gunicorn with 2 workers and 2 threads each (4 concurrent execution contexts). My custom logging function writes to a file without any process-level locking:
def ...
1
vote
0
answers
59
views
Python Flask app connected to Cassandra Astra DB RAM memory issue
I'm running a minimal Python Flask app with one API endpoint which make a simple call to retrieve data from the a Cassandra Datastax DB inside a for loop.
# Day-2-Day Power
@app.route("/d2d_new_2/...
1
vote
1
answer
67
views
Flask Post api not returning created object data as response
I am writing a flask sample application in which I have the following model and schemas.
PlainStore schema is as following:
class PlainStoreSchema(Schema):
id = fields.Str(dump_only=True)
name ...
0
votes
1
answer
39
views
How do I turn on logs when using Gevent with Gunicorn?
I used to use eventlet to run a flask app on Render.com. It would show detailed logs on render every time an HTTP request was made like GET /socket.io/?EIO=4&transport=polling&t=PcGtd0M HTTP/1....
705
votes
15
answers
947k
views
Return JSON response from Flask view
I have a function that analyzes a CSV file with Pandas and produces a dict with summary information. I want to return the results as a response from a Flask view. How do I return a JSON response?
@...
636
votes
8
answers
876k
views
How can I get the named parameters from a URL using Flask?
When the user accesses this URL running on my flask app, I want the web service to be able to handle the parameters specified after the question mark:
http://10.1.1.1:5000/login?username=alex&...
1
vote
1
answer
84
views
Google Cloud Run Using Flask
I am trying to run some functions that collect data from GCS buckets to BigQuery using Flask. I have deployed the API successfully on Google Cloud, but whenever I do a GET request on the home page, it ...