Questions tagged [flask]
Flask is a lightweight framework for developing web applications using Python.
50,286
questions
0
votes
1
answer
15
views
TypeError: __init__()
I am new to coding and I am following along on a tutorial. Try to explain things in simpler terms please. Here is my .py code on Visual Studio. I am trying to create a database to save and delete ...
0
votes
0
answers
6
views
How to display the recipe with the highest like- Python Flask with Peewee
I am new to flask and I have created a flask api where user can upload recipe and also like recipes. To get the top recipe, I want sort recipe by the highest number of likes.
@app.route('/top_recipe', ...
0
votes
0
answers
6
views
Updation of shared global object - Prevent Racing
I'm creating an API server using Flask that responds to 2 types of requests - queries and updation. Internally, an object rec is used to carry out computations.
When rec is initialized, some data from ...
1
vote
0
answers
8
views
HTML - Flask - open a new page on button click without using Javascript
I have a table with a feature to select value of a row to send it to the Flask backend, that on button click also redirects my users to a different endpoint. What I need is to open the new endpoint ...
-1
votes
0
answers
8
views
Return a content from a text file in Flask [duplicate]
I tried to return a content from a text file in Flask but I have only the name of the file not the content
return "http://{ip}:{port}/s/{x}.txt".format(ip=ip, port=port, x=x)
-1
votes
0
answers
12
views
Flask request.form.get returns Nonetype [duplicate]
I have read through and rewrote this code a few times now but still i can't seem to find the mistake.
The code is as follows(not done yet so it acutally doesn't really do anything until now):
@app....
0
votes
0
answers
12
views
How can I display the content string in multiple lines in flask using Jinja? [duplicate]
I'm trying to display the post.content in multiple lines. I tried to replace \r\n with but it's still not working.
My request method:
title = request.form["title"]
content = request....
-1
votes
0
answers
14
views
Flask error/trouble initializing flask: how to correctly import flask in python?
I have been working on resolving this problem for about a day now, but I have not figured it out. So I sincerely appreciate any help or feedback you may give.
Basically, I am trying to just import ...
-2
votes
1
answer
25
views
AJAX to get data from Flask server back to client
I have a button that submits a user input form:
<input class="btn btn-dark" type="submit" name="submit_button" value="View Code" id="retrieve">
...
0
votes
0
answers
10
views
Python unit test failing even though the expectation match
I'm sure as of writing this there is something very basic I'm missing here...
I have following python function
## views.py
from flask import request, jsonify
log_obj = EdgeLogger(name='edge_api')
...
-1
votes
0
answers
5
views
Flask return in memory pdf [duplicate]
I wrote this POST endpoint that fill an html tamplate with the user input and generate the equivalent PDF with pdfkit but it always return status: 500 and I see that the response's header are not set ...
1
vote
0
answers
27
views
Get columns values by a primary key, sqlite
I was working on this project using flask, and I am trying to create a route where you can see a post's info (every post's an ID insert in a table like a primary key)
I was trying to display the row ...
0
votes
0
answers
8
views
Flask in Sveltekit deployed on Vercel
I am running a simple python script connected to a Sqlite database. I am bringing this to the web with Flask and a Svelte front-end.
Everything works on the dev environment (running the Flask server ...
-1
votes
0
answers
6
views
How To Transfer HTML Lists To Flask Python With The Method POST?
This is the function I call in python using flask:
@app.route('/display', methods=["GET", "POST"])
def display_list():
if request.method == "POST":
data = request....
0
votes
0
answers
8
views
How can I do this query in Flask-SQLAlchemy?
is it possible and how this querie in a flask with SQLALchemy
SELECT * FROM records
WHERE status = 'SCHEDULE'
OR status = 'RECORDING'
OR status = 'FAILED'
AND fail_type='S3_CONNECTION'
I am using the ...
-1
votes
2
answers
23
views
flask application not running [duplicate]
from flask import Flask
app=Flask(__name__)
@app.route('/admin')
def admin():
return "the current user is admin"
@app.route('/student')
def student():
return "the current user is ...
-1
votes
0
answers
14
views
Move variables into configuration file
I have a python flask application that relies on global variables that hold information about configuration.
My plan is to move them outside of the main server.py file and in another configuration ...
-3
votes
0
answers
12
views
removing Double deployment links flask
The image shows the double links during testing, it affects my deployment on aws, is there any way to remove it
-1
votes
0
answers
13
views
Unable to get TCP client working in Flask APP
I have 2 programs running on a server with TCP service to communicate with the outside world. Now I would like to implement a FLASK App as an intermedium service to pass information between the ...
0
votes
1
answer
17
views
Serverless command return "This is serverless"?
I have a python project (flask) with PostgreSQL, and I tried to run the command sls wsgi serve
And I got this kind of 'error'
Does anyone know why I got this?
0
votes
0
answers
16
views
Flask-Sqlalchemy doesn't work as expected when use filter by
Hello I am triying the following querie
record = Record().query.filter(
Record.id == record_id,
Record.status.isnot(Status.COMPLETE)
).one()
print(record)
status is a str and id is a int
...
-1
votes
0
answers
18
views
TemplateNotFound index.html but template folder is ok [duplicate]
I have my project structure like this:
Wheather-App/
controllers/
core/
settings/
models/
static/
templates/
index.html
run.py
In other questions on StackOverflow ...
-3
votes
0
answers
29
views
'dict' object has no attribute 'phone_id' what could be the possible solution [closed]
try:
params = {
'phone_id' :'********',
'_csrftoken': '********',
'guid':'********',
'device_id': '********',
'_uuid': '********'
...
0
votes
1
answer
25
views
VScode Debugger Not Working with Flask-Script Commad
I have a command created with flask-script and I want to debug it with VSCode debugger.
But when I run the VScode Debugger configured for Flask, it simply executes the command without stopping at the ...
-1
votes
0
answers
13
views
COULD NOT IMPORT "FILENAME" Python Flask
How should I do to fix error in my project
when I flask run
there are error: Could not import 'main'
I can't send the picture because 10 reputation not yet
0
votes
1
answer
27
views
Flask API MySQL queries
I'm playing around with an inventory database and trying to make a REST api with flask.
I want to be able to hit a url like http://myapp.com/products, which returns JSON of all the products in the ...
0
votes
1
answer
27
views
How to close opencv video stream from flask
I've implemented a system to capture faces on-the-fly from a live stream using flask and OpenCV. I'm now facing difficulties with closing the stream and releasing the VideoCapture object. Here is a ...
-1
votes
1
answer
27
views
Simplest way to securely distinguish between admins and other users in Flask
Forgive my naivety here, but I've been looking into various solutions for role authentication in Flask, and it seems that several extensions are no longer being maintained. This got me wondering ...
-2
votes
0
answers
14
views
Why is Flask giving me an Internal Server Error? [duplicate]
Here's the code :
from flask import Flask,render_template
app = Flask(__name__)
@app.route("/")
def home():
return render_template("debut.html")
if __name__ == "__main__&...
0
votes
0
answers
12
views
Flask: Elastic Beanstalk always giving a 502 Bad Gateway error when trying to request favicon.ico
I've been trying to deploy a very simple flask app onto AWS. But I just can't seem to make it work. It always gives me the same error that favicon.ico is not found in the console and gives me a 502 ...
0
votes
0
answers
19
views
nginx gunicorn sock / 400 BAD REQUEST / *21 connect() to unix:*.sock failed (13: Permission denied while connecting to upstream
Edit: I've updated my directory for my socket to /var/run/myapp.sock. It doesn't seem to affect runtime, but it may be important.
So, I've got this API I'm trying to get up and running. It worked ...
0
votes
0
answers
16
views
cur.execute(sql,params) sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type
I am currently having a problem with my code. I know that there are many answers to this question on the website, but I tried everything, and I didn't manage to solve the problem.
I am using flask, if ...
0
votes
2
answers
32
views
How to use microsoft oauth2 using azure AD with angular + flask
I'm developing a flask + angular web app, and I want to use Microsoft oauth2 to get some data using rest APIs.
So I have a "sign in to Microsoft" button in Angular, but I need to call the ...
-1
votes
0
answers
15
views
Click a button goes to another webpage in flask
I want to go to the html file AimTrain.html when i click the first button, and I'd like to go to Teste.html when I click the second button. Was wondering how is this possible using FLASK.
HTML
<...
-2
votes
0
answers
17
views
SwaggerUI from API gives CORS Missing Allow Origin [closed]
I have a flask restful api that resides in a cloud service. I have implemented the url to the flask app to be allowed in cors in the cloud provider. When I try to run a swagger command I get "...
0
votes
0
answers
6
views
Procedual Generated Filter Argument for MySQL with Python
I'm working on an Interface for my MySQL Database.
In this interface I want to have an Table Output where the User can search for any Information with any Filter from all columns they would like.
For ...
-1
votes
0
answers
19
views
Create Python file in Visual Studio 17.2 and auto-reaload the server
After creating the Django or Flask project in VS 2022 and run the server. The button Add only have option -> Django app. Only stopping the server the option add New Item is enabled.
For instance I'...
-2
votes
1
answer
27
views
Display result (format) from Python to HTML webpage
I'm wondering is it possible to display the result (including the format) from Python on HTML?
I got the following result from Python (extracted by the Mysql database), and I want to keep the same ...
-1
votes
0
answers
18
views
Python/Flask webpage @app.route not working
Can someone please help me understand why the following code is not working when I use it inside the simple while loop:
app = Flask(__name__)
@app.route('/')
def index():
return render_template('...
0
votes
0
answers
17
views
How to map table relationships with flask-sqlalchemy, before tables exist?
I have a problem creating relationships between my tables in flask-sqlalchemy. I have a table with project overview, and from there on out I want to dynamically create new experiment tables with a ...
0
votes
0
answers
8
views
Is sqlalchemy infinite
I want to know that can sqlalchemy database save infinite amount of data or there is a limit?
Please tell me.
I am making a application and I want to know whether this database can save infinite data ...
0
votes
0
answers
14
views
FlaskForm not accepting field name 'process'
When I put the name of the field to 'process', Flask fails to process my form.
Here is the example code:
from flask import Flask, render_template_string
from flask_wtf import FlaskForm
from wtforms ...
0
votes
0
answers
15
views
Recording user audio with HTML+Flask
I am working on a site using python anywhere combining Flask and HTML, I need to get audio input from the user and then save their recordings on a server. Right now I am using <input type=file ...
0
votes
0
answers
8
views
get Alert Bootstrap 5 autoclose
Good afternoon, I am with a Flask project and for the frontend I use Bootstrap 5. I would like to know how I can make the alert that reports the action executed in the DB close automatically after 2 ...
0
votes
0
answers
17
views
Search & Add Member on the same webpage
I'm just wondering is it possible to put search the existing users' function & add a new user function on the same webpage?
It's similar to the screenshot below. But I am trying to do it in the ...
-1
votes
1
answer
23
views
passing variable to a table in flask
I am following this video and everything is working perfectly. The output of a SQL query is saved within a variable that I can call on in another .html page.
so my sql query is:
@app.route('/...
0
votes
0
answers
7
views
boto3 Flask problem Exception on /upload [POST]
I have problem with Flask app. App runs on server but when i want to upload a file to S3 I get a error 500 in browser.
In SSH client:
Exception on /upload [POST]
TypeError: expected string or bytes-...
-1
votes
0
answers
24
views
Flask generates urls of my images with "%5C" instead of "/" and therefore does not display these images [duplicate]
I realize a catalog of products in flask + python; when I execute I don't have images of the products; and when I check behind the browser the code does generate the url of the image but with weird &...
-3
votes
0
answers
23
views
Best way to let user make a ranking in HTML [closed]
I am making a website in Python Flask where people have to vote on candidates. After they vote I change some numbers and ask to vote again. They have to vote with a ranking.
<ul id="candidates&...
0
votes
0
answers
13
views
Flask Decorator: Timeout of password
I'm building a FlaskApp and i have a Decorator Function that asks for a username and password upon vising the page. It's working fine but i want to re-ask for the credentials in a specific interval, e....