Click here to Skip to main content
15,881,803 members
Everything / Web Development / Flask

Flask

flask

Great Reads

by Ahmed Bouchefra
Possible ways that you can use to connect or integrate Python with Node.js and Electron with simple examples
by SimbirSoft
A bit about Python & Flask

Latest Articles

by Ahmed Bouchefra
Possible ways that you can use to connect or integrate Python with Node.js and Electron with simple examples
by SimbirSoft
A bit about Python & Flask

All Articles

Sort by Score

Flask 

24 Feb 2020 by MadMyche
The problem you are experiencing looks to be caused by having a relationship between the 2 tables involved (share / attachment) and trying to delete an entry from the table with the PrimaryKey.DBAPI Errors IntegrityError Exception raised when...
30 Aug 2022 by Richard MacCutchan
That looks like the content of a flask template file, which is used to build a web page. See Welcome to Flask — Flask Documentation (2.2.x)[^]. However, if you are new to coding you may well find flask difficult to understand unless you have a...
19 Aug 2019 by Ashirwad Satapathi
Hello daviddoyyer32 If you intended a to have a buffer of a certain time then there are multiple ways to do it. One of the easiest way is to use the sleep method(function) from the time package. Code: import time def aFunction(): time.sleep(60) # Delay for 1 minute (60 seconds). Hope...
7 Nov 2019 by Peter R. Fletcher
The behavior of the following chunk of code has me tearing my hair out! It is from one of the 'routes' in a fairly complex Flask application, which I am writing to schedule Wemo devices. This is only a section of a much longer piece of code, and its purpose is to handle edits to the weekly...
28 Apr 2020 by Ahmed Bouchefra
Possible ways that you can use to connect or integrate Python with Node.js and Electron with simple examples
21 Jan 2021 by Christian Graus
The URL is wrong. There is no URL in your code, ergo, your code is not the issue. You need instead to use your debugger. Why on earth would you not calculate this with sql using SUM?
21 Jan 2021 by pythonHumanBot
I changed the button from a href to bootstrap modal fixed the 404 error, thank you again Christian!
18 Mar 2021 by lukeer
In an attempt to find out how other web servers on the same machine would be treated, I started$ winpty python -m http.server 5000 (Found that somwhere in the internet). That triggered the firewall to tell that it had just blocked python.exe and...
7 Jan 2022 by Ebuoe
I just hosted my flask app for the first time online, everything seems to be working fine so far except for the sessions, which are not persistent. I have tested the app severally on my local server using the inbuilt flask and gunicorn server ....
8 Mar 2022 by lukeer
Got it. That __name__ == "__main__" check fails when debugging because Visual Studio Code doesn't start app.py directly but something called launcher instead. VSC also passes launcher some obscure arguments that tell it to start and debug...
22 Jun 2022 by Richard MacCutchan
Take a look at Testing Flask Applications — Flask Documentation (2.0.x)[^]
25 Aug 2022 by OriginalGriff
In Jinja, endif is one word, not two end if: Template Designer Documentation — Jinja Documentation (3.0.x)[^] {% if title %} Flask Blog - {{title}} {% else %} Flask Blog {% end if %} Should be: {% if title %}...
22 Sep 2022 by OriginalGriff
Read the error message, it's really clear: The crypt module is not supported on Windows It's Linux specific, very simple, and not compatible with modern systems such as SHA (or even the broken MD5!). Think about exactly what you are trying to...
10 Dec 2022 by CodeGuru84
It looks like the home function in your routes.py file is defined as part of a Flask blueprint named main. When using a blueprint, you need to prefix the endpoint name with the name of the blueprint when generating URLs using url_for. In your...
13 Feb 2023 by OriginalGriff
Without your code, we can't help specifically. Try here: SO: "InvalidRequestError: Object '' is already attached to session"[^]
13 Apr 2023 by Richard Deeming
You're making a GET request to the delete_image route, using an tag, so you won't be able to include hidden fields in the request. But endpoints which create, change, or delete data should never accept GET requests. Some browsers or...
22 Apr 2020 by SimbirSoft
A bit about Python & Flask
4 Jun 2019 by Nagy Vilmos
There may be a better way to do this, please let me know if there is. We have an API served by a Flask web server; this can't be changed. We have web client - SPA using react providing dynamic content served by the API. We want to deploy this all via Elastic Beanstalk in AWS. What I really...
19 Aug 2019 by daviddoyyer32
I want to call a function in flask that takes 1 minute to compute, how do i do this after showing the "main" template? What I have tried: @app.route("/main") def mainPage(): aFunction() #takes 1 min to run return render_template("main.html") # shows the template after 1 minute
24 Jul 2019 by daviddoyyer32
when i run my flask server, i get this message spammed about every 15 seconds why is this? how can i stop it? What I have tried: 192.168.1.42 - - [24/Jul/2019 14:08:35] "POST /inform HTTP/1.1" 404 -
24 Jul 2019 by Patrice T
Quote: What does this mean in flask? The error message tells you there is a problem, you have to track down which page is not found and correct the request. 192.168.1.42 : Ip V4 address [24/Jul/2019 14:08:35] : DateTime "POST /inform HTTP/1.1" : Escaped text to highlight it 404 :...
13 Feb 2020 by Richard MacCutchan
A script will not do it unless you can get access to the data. And what exactly do you mean by "the telephone directory numbers of any country"?
14 Feb 2020 by OriginalGriff
No, you would have to access - and almost certainly pay for - that info on a country-by-country basis: it's valuable information (even if incomplete, I'm not on it for the UK for example) to advertiser, spammers, and cold callers so phone...
24 Feb 2020 by Matix who codes
Hello, I have a small webapp using flask and sqlAlchemy. Im currently stuck at one problem. The problem is that I can not remove entries from the database using sqlAlchemy. The error wich gets returned: sqlalchemy.exc.IntegrityError:...
25 Mar 2020 by Michal Issa
Hi everyone, I am facing a hard time since I could not figure out how to redirect to the previous URL. When I tested request.referrer 10 days ago, it worked, but now it's not working anymore and instead, I am getting the same URL. I am creating...
30 Mar 2020 by OriginalGriff
To be honest, if you have to ask these questions, then you shouldn't be going near this project yet: you are dealing with real money, and that means two things: 1) You need to know exactly what you are doing, and do it correctly, or you will...
16 Apr 2020 by Member 12470462
I've been having issues in storing variables(parameter replacement) into the database in postgresql using flask; below is what i did but it was not executed; what could be the issue username: 'Pat' email: 'pat@gmail' password:...
16 Apr 2020 by RickZeeland
Maybe you need to make a connection first, see example here: How to Execute Raw SQL in SQLAlchemy | Tutorial by Chartio[^] It could also be that your changes are executed but not committed, so you might need to use something like this: result =...
25 Apr 2020 by Member 12470462
Hello everyone, i'm currently working on a login system in flask, and i want to send session variables to a landing page after the login and then retrieve them there, (NB: I'm not making use of flask-login and i dont want to parse the variables...
7 Jul 2020 by Member 14883710
var buttonclicked; $("#testbtn").click(function(){ if( buttonclicked!= true) { buttonclicked= true; if (post.post_variable ==...
7 Jul 2020 by Richard MacCutchan
You never increment the counter if buttonclicked is true. Try modifying the code thus: if( buttonclicked!= true) { buttonclicked= true; if (post.post_variable == "NULL") post.post_variable = 0; alert("Button is clicked for...
7 Jul 2020 by Andre Oosthuizen
You can try the followin - HTML 0 Java $(function() { $('#testbtn').click(function() { $('#output').html(function(i, val) { ...
20 Sep 2020 by Member 13998042
how to serializ the date time object in python api i have a api which will give json output and i am trying to save it as excel using xlsxwriter and i am getting this error Object of type datetime is not JSON serializable this is the api...
20 Sep 2020 by OriginalGriff
Have a look here: Python Serialize Datetime into JSON[^]
20 Sep 2020 by Sandeep Mewara
Generally, using of json.dumps with a custom converter. Quote[^]: The json.dumps method can accept an optional parameter called default which is expected to be a function. Every time JSON tries to convert a value it does not know how to convert...
19 Jan 2021 by Fynn Pfingsten
if i run this code: from flask import render_template import connexion # Create the application instance app = connexion.App(__name__, specification_dir='./') # Read the swagger.yml file to configure the endpoints app.add_api('swagger.yml') ...
21 Jan 2021 by pythonHumanBot
Hey guys, I'm trying to sum the rows of the products cost into the portfolio table, so I inserted a refresh button in my flask page to do that that calls this function. I need the sum part to work, and then I can safely add the commit to the...
22 Feb 2021 by lukeer
Hi forum, a colleague of mine has created a marvellous piece of HTML and CSS that leaves me astonished what UIs are possible with web programming skills. I am responsible for the backend in python. I have a connection to a real-world...
10 Mar 2021 by lukeer
Hi forum, to use Socket.IO, our server has to use a library called flask_socketio. Its clients will be browsers. They need a Socket.IO implementation, too. Therefore, the index.html that the server distributes includes
24 Feb 2021 by Richard MacCutchan
Did you try Welcome to Flask-SocketIO’s documentation! — Flask-SocketIO documentation[^] ?
2 Mar 2021 by jaideepsinh
I am trying to create an azure ci/cd pipeline for my python application. I have tried many ways but not get success. I can create CI successfully even in some cases cd also but not able to see the output on the azure app service. I use Linux app...
2 Mar 2021 by jaideepsinh
Solved by configuring the steps as mentiond in below post: flask - Azure devops for Python - Stack Overflow[^]
18 Mar 2021 by lukeer
Hi forum, there is a python program using flask and socket.io to create a web server which runs on my development machine. On the same machine, I can access the server and get the website it serves by typing localhost:5000 in the address field...
13 Oct 2022 by meister meister
I have a function that the user can add a budget. In the python shell, when I am adding a budget there is no error. But when I am going for the route where I am adding my budget, it gets an error. This is the error I get: ...
17 Mar 2021 by meister meister
I have a function that output Average Budget and Average Salary, the problem is when the computation executed for the average salary, also the average budget affected. I tried to use simple .copy() routes.py: @app.route("/user/",...
22 Mar 2021 by nainish aggarwal
Here is my code for searching a keyword in Docx files present in the folder. It should show all the Docx files which contain the keyword. But here when I use AutoIndex it only showing the whole directory as the output and I want that the...
25 Mar 2021 by Saurabh Nadar
I am making a dynamic blog using flask but when i try to connect to the databse i get the error in the title. Here's my code. from flask import Flask, render_template, request from flask_sqlalchemy import SQLAlchemy from datetime import datetime...
25 Mar 2021 by Saurabh Nadar
I found the problem. Somehow “SQLAlchemhy” was not working properly. So i only had to uninstall and reinstall it. Giving this answer so that it could be helpful for someone in future.
24 Aug 2021 by Dev-Elie
I am trying to send data from a contact form to email using python. I've tried several ways that don't seem to work. The data is from a random user, then the data should be forwarded to a specific email, not the same email receiving the message...
24 Aug 2021 by Richard MacCutchan
Try using the preferred port number for SMTP: https://www.mailgun.com/blog/which-smtp-port-understanding-ports-25-465-587/[^]. You should also check any response codes to see whether your calls succeeded or not: smtplib — SMTP protocol client —...
1 Sep 2021 by Scieoner
The code itself: import redis, sqlite3, time from flask import Flask, render_template, request, g, current_app app = Flask(__name__) r = redis.Redis(host='localhost', port=5000, db=0) conn = sqlite3.connect('trade.db') cursor = conn.cursor()...
19 Sep 2021 by jcjakec
Sorry if this is a little vague. I have been attempting to use build a simple table. I have been following this tutorial, though when I run the site, the css doesnt seem to work. some parts do, for example the row colouring, but nothing else....
20 Sep 2021 by Thor Odinson 2021
I am trying to make a website which has solutions of a book (5 chapters). Firstly, I want to open chapters.html with route /chapters which displays five submit buttons and chapter no. as their values. And when the button is clicked,...
19 Sep 2021 by Richard Deeming
Quote: "> You've got an extra > on the end of your class name, which isn't valid. It should be: But looking at that code, I don't think much of the tutorial you're following. Using CSS...
7 Feb 2023 by Grace Clarke
I have created a program in python, which is an online store which users can add products to their cart and checkout etc. For the final part I want to finish it with it set up in flask for its own web page. from flask import...
22 Oct 2021 by Richard MacCutchan
See Tutorial — Flask Documentation (2.0.x)[^]
3 Nov 2021 by Mahathir Mohammad Shuvo
I host a flask app in Ubuntu 18.04 LTS with Nginx and Gunicorn. I use Flask-SocketIO==5.0.1 for backend and "https://cdn.socket.io/3.1.3/socket.io.min.js" for front end. here is my server configuration: server { server_name toollaza.com; ...
6 Nov 2021 by Richard MacCutchan
Sorry no. This site does not provide free code conversion services.
12 Dec 2021 by Rakyat Monster
I am writing an application of RobotChat to be 24hours customer-service for answering the questions of the buyers/customers. I use Python, TelegramAPI, dan Flask. My program of this-application can work properly if I run it on local-computer...
24 Dec 2021 by Member 13969713
I am using an online IDE to test a flask project, but whatever I do, I get a web page that gives localhost refused to connect error. It happens when I submit a form, and it is supposed to redirect to another page. Further more, I tried to run...
24 Dec 2021 by Member 13969713
Well, I found a solution to this. It turned out, that the url provided in the form action section >http://localhost:8000/result should instead be /result so that it's a relative address instead of an absolute address.
22 Jan 2022 by Herme97
Hello everyone I want to slice a string on a flask template in python. Actually what I want to do is by using an if statement to make a link to something like "Read More" or just "..." I tried the following in html and flask files respectively...
8 Mar 2022 by lukeer
Hi forum, atm, I'm able to 1) Use Visual Studio Code's debugger on my flask socket.io application and 2) serve clients that are not my development machine but not both at the same time. To use the debugger, I just hit "F5" from within VSCode....
15 Feb 2022 by Tasmiya Bano
I have a flask server running in background i.e. created a .service file and initiated the flask application. Now, when I fire flask APIs from launcher file, I am unable to see logger messages on console. I am doing this to add verbosity option...
8 Mar 2022 by bingusCoder
Hello there! I'm trying to make a website with a database, but when I commit an user's account to the DB, I get a sqlalchemy.exc.OperationalError I'm using flask to make the website. Is there anything I can do to fix this? Here is the code...
8 Mar 2022 by lukeer
Hi forum, there's an application ("the backend") using python flask socket.io. Multiple browsers ("the frontends") may connect to this application at the same time. One of the use cases requires that the backend sends a message to one of the...
8 Mar 2022 by CHill60
As per my comment, you will need to generate the database from your model using the create_all method - see API — Flask-SQLAlchemy Documentation (2.x)[^] Also this reference might help : Quickstart — Flask-SQLAlchemy Documentation (2.x)[^]
21 Apr 2022 by Kaushik Vezzu
As a part of my project involving conversion of sign language to english , I developed .tflite model and did predictions successfully using opencv. Now i want to implement web application for this . On the web page , there will be live streaming...
17 May 2022 by Tyrunt.new("Rix")
Hello, coding guys, As you saw in the title, my Python API returns a 404 page when a page is found, like /python/ should return "print("Hello, world!")", but returns 404 instead. This is my code: from flask import Flask, send_from_directory,...
27 Jun 2022 by Jackie Lloyd
I am new to Python and Flask, and have inherited some Python Flask code, and my task is to write tests for it - bad process I know but we are where we are :/ I have read lots of similar problems to mine but still none of them work in my...
2 Jul 2022 by Kavya Bhargava
I am new to Django, I was following a tutorial. I am trying to display my jobs from model.py to HTML Models.py: class Jobs(models.Model): FULL_TIME = 'FT' PART_TIME = 'PT' REMOTE = 'RT' TIER1 = 't1' TIER2 = 't2' TIER3...
3 Jul 2022 by Kavya Bhargava
I built a simple signup form which will take data as user will click submit it will save it in database. But for some reason I am able to validate it. I removed all the validations and added again too. Not sure where I am missing? Forms.py: ...
2 Jul 2022 by Member 15678123
There a typo in the code {% for job in jobss %} Should be {% for job in jobs %}
31 Jul 2022 by Jackie Lloyd
I have a python Flask app. If the user types characters into a search field fast then the wrong results can be displayed becuase there is a lag in getting the data. If another character is typed then the results are shown which are for the...
14 Jul 2022 by Kavya Bhargava
My form is receiving data when I put values in it but it is not displaying it in HTML. models.py: user = models.OneToOneField(User, on_delete = models.CASCADE) image = models.ImageField(default = 'default.jpg', upload_to =...
31 Jul 2022 by Jackie Lloyd
I have accepted this solution as it would be a good one if I hade correctly diagnosed the problem in the first place. (I also would give it 5 stars but for some reason it only seems to allow me to select 4). It actually turned out that the...
15 Aug 2022 by Richard MacCutchan
You need a method to get the database reference, the db variable does not exist in the functions you are using. See Welcome to Flask — Flask Documentation (2.1.x)[^] for details of how to do it correctly.
22 Aug 2022 by Member 15744868
Using flask SQLAlchemy and SQLite I have a database for a game. In this game I need to combine 2 elements to make a third. the first element comes from the column Main and the second is the name of a column where, in that row of main, the final...
22 Aug 2022 by OriginalGriff
Assuming that main, fire, water, air, and earth are your column names, it's simple: SELECT water AS Combination FROM MyTable WHERE Main = 'fire'
24 Aug 2022 by Richard MacCutchan
See Handling Application Errors — Flask Documentation (2.2.x)[^].
25 Aug 2022 by Aalam Pratap Bedi
I have a folder named Python Project 01. It has 2 sub folders templates(for html)(it has two folders- home.html and about.html) and flaskblog (for python ) The code for my flaskblog is- from flask import Flask, render_template app =...
30 Aug 2022 by Aalam Pratap Bedi
{% for post in posts %} {{post title }} {{post author}} {% end for %} What I have tried: I am beginner in coding so i am just curios about this question.
2 Sep 2022 by jon773599
My Flask code look like # A very simple Flask Hello World app for you to get started with... from flask import Flask,Response from flask import request from bs4 import BeautifulSoup import json app = Flask(__name__) if '_name_' ==...
2 Sep 2022 by Richard MacCutchan
You do not show which is line 15, but I cannot see a line like: r = request.get(url) However, I suspect what you need is: r = request.args.get(url) as you have in the above code. See also 3. Incoming Request Data — Flask API[^].
2 Sep 2022 by Richard MacCutchan
Why have you posted this? It is exactly the same issue as R = request.get(url) attributeerror: 'request' object has no attribute 'get'[^], which I have already answered. Please do not repost the same question.
15 Sep 2022 by Apoorva 2022
I worked on an NLP project that can extract information from a resume like Name, Skills, Email, Designation etc. I built the project using Regular Expressions & stored the predictions in a variable. What I have tried: My prediction variable...
15 Sep 2022 by Richard MacCutchan
You can start at Welcome to Flask — Flask Documentation (2.2.x)[^] for creating a Flask application. But I have no idea how you integrate that in Colab.
29 Nov 2022 by Richard MacCutchan
Given the fact that you are asking other people to advise on how to make this project, I would suggest it is not a good choice. You should go for something that you already understand so you can get straight on with the actual design and coding.
29 Nov 2022 by OriginalGriff
Quote: Hi, we have already taken this project as final year project, i am asking if this project is correct choice for a final year project If you have already decided, then that's a moot point. Is it appropriate in my opinion? No. Firstly, as...
29 Nov 2022 by Dave Kreskowiak
So how do you plan to predict the impact of social media posts of certain celebrities on the price of crypto? Yes, it happens, and that's why I don't gamble in crypto markets.
10 Dec 2022 by Aalam Pratap Bedi
The error I'm getting- werkzeug.routing.exceptions.BuildError: Could not build url for endpoint 'home'. Did you mean 'main.home' instead? Code for my routes.py folder- from flask import render_template, request, Blueprint from...
10 Dec 2022 by Richard MacCutchan
Try the following change: return render_template('main/home.html', posts=posts) # add the 'main/' prefix to the template name. and the same for 'about'. [edit] Looking at the structure of my flask application I would suggest that all the...
1 Feb 2023 by Chiranjib Parida
Showing Internal Server Error in flask python from prettytable import PrettyTable from flask import Flask, request app = Flask(__name__) @app.route("/", methods=["GET", "POST"]) class Structure_Cal: def __init__(self, Slope,...
3 Feb 2023 by j ton
I see this on web, I want to try myself but stock - .py (can get sql data and pass on index_test_0203.html) import mysql.connector import webbrowser import time import pymysql from flask import Flask,render_template,request app =...
2 Feb 2023 by Richard MacCutchan
I suggest you take a look at Welcome to Flask — Flask Documentation (2.2.x)[^], and work through the tutorial.
13 Feb 2023 by Josephine Anne Nacman
When we try to edit and delete a user in our crud, that error shows up. What I have tried: I don't know what step should I do
31 Mar 2023 by OriginalGriff
Repost: Deleted. Please do not repost your question; use the Improve question widget to add information or reformat it, but posting it repeatedly just duplicates work, wastes time, and annoys people. I'll delete this one.
19 Jun 2023 by Richard MacCutchan
Check that your settings match those that are listed at https://medium.com/@dpralay07/deploy-a-python-flask-application-in-iis-server-and-run-on-machine-ip-address-ddb81df8edf3[^].
23 Jul 2023 by Dragynjump
I'm looking to deploy a website I made using flask, but I need help finding the right web host. It contains a python configuration file, html files within a "templates" folder, a css page, several javascript files, and images contained within a...