Questions tagged [flask]
Flask is a micro-framework for Python based on Werkzeug, Jinja 2 and good intentions.
148
questions
0
votes
1
answer
28
views
Create-flask-app with a single commend
Lately I was creating a loot of flask apps and I was getting a bit annoyed typing each time all the commands (make venv, flask env, pip installing, gitignore...)
So I decided to make a package that I ...
0
votes
0
answers
86
views
Many to many relationship in Flask with SQLAlchemy
I want to create a family tree where the relationships are only godfather and godson. Is this the right way to declare the personn class ?
...
0
votes
1
answer
35
views
Flask-SQLAlchemy achieve 1 to many relationship that backfills parent when child is updated
Currently I have two tables Plan (plans) and User (users) and there is a foreign key constraint on users which references plans.id
When I create a new user I want to assign a plan to that user via ...
2
votes
0
answers
57
views
Flask API application to serve SPA webapp
I've recently started learning python to gain some fullstack skills and am working on a backend for a webapp as a learning project. Before I get too far down this path I was wondering if someone ...
1
vote
0
answers
46
views
Injecting dependencies in Flask routes without a DI framework
I was wondering what might be the best way to inject Flask routes dependencies without a DI framework.
I came up with something like this (CalculationService being ...
1
vote
0
answers
30
views
bit.ly Clone in Python powered by Flask
Recently, I was studying flask and my friend sent me a bit.ly link. Then the idea of a bit.ly clone struck my mind.
This project uses
Python - 3.10.0
flask - version 2.0.2
Bootstrap CSS. (I am very ...
0
votes
0
answers
278
views
Rendering Radio Buttons Individually in WTForms/Jinja2
I'm building a contact manager with Flask for a community group, and I'm working on the function to export contacts as a spreadsheet. I want to export either all contacts, only those who have been ...
4
votes
2
answers
59
views
Flask static url view
The code runs fine and was manageable without any error handling.
Once I started to handle errors and build out the code the if/elif/else branches quickly became too much. How can I route the view ...
3
votes
2
answers
54
views
Displaying validation messages for an input form
I'm trying to capture all input fields in a form (i.e. sign_up.html) & validating them - if one of them is null or empty then it should show a validation message. I've done it but I'm looking for ...
1
vote
0
answers
58
views
Flask API for converting Contact Form responses to Email notifications (with reCAPTCHAv2)
Introduction
I wrote a proof-of-concept Flask server that accepts responses from a contact form and converts the data submitted to an email. I have added a rudimentary honeypot field that causes the ...
2
votes
0
answers
72
views
Flask Session + Jinja OR Javascript + Flask
I'm a beginner in programming and I'm figuring out what is the best approach for my mini e commerce site project.
My current approach is
...
2
votes
1
answer
80
views
Python app thats simulate simple Stock Exchange
I wrote this simple app for creating a Stock Exchange platform.
It is written with a flask framework.
My main concerns are regarding the user_page route which feels too long and not DRY enough,
But on ...
0
votes
2
answers
140
views
Getting a username from a database and displaying it in HTML
I'm using Flask on Python and I'm displaying the username at the top of the site (and it's working) as follows:
...
1
vote
1
answer
214
views
Read and display JSON results from Google Books API
I’m working with the Google Books API and I’m not so sure about the way I’m going to get the search data and return it to the user. I will describe the path here and I would like to know if you would ...
4
votes
1
answer
92
views
Python Rubiks cube solver - general code comments
I have been learning Python/Flask for the past 5 months outside of full time work and have just finished a first complete version of an app:
Working site: https://rubiks-cube-solver.herokuapp.com/
...
2
votes
1
answer
123
views
Query the github api and filter the last 1000 commits which include and exclude certain words from the top 3 repositories in a given organization
This code should query the github api and filter, out of the last 1000 commits, which ones include and exclude certain words from the top 3 repositories in a given organization.
For example, I could ...
2
votes
1
answer
855
views
Run python File With get request flask API
Code is Working Review and Recommend What Are Best Practice
What I am trying to achieve.
API with Flask that runs any python file from the current directory.
Run the file and get output in JSON
...
1
vote
1
answer
40
views
text-messaging app using twilio
I build a small web-app using flask for my parents to text their customers about promotions. I am using Twilio API. I just finished the myapp.com/new-campaign page ...
2
votes
1
answer
105
views
Python: separation of concern User Model and User DB
I am working on a small side-project since a couple of weeks, I am using Flask but trying to use as few libraries as possible and no ORMs (for learning purposes.
I am currently working on the User ...
0
votes
0
answers
245
views
Fastapi with Aiohttp not providing expected results
I am new to asynchronous programming in python. Below are two scripts(which perform the same operation) one in Fastapi + aiohttp while other is basic Flask + requests library:
...
1
vote
1
answer
42
views
Populate database of web articles
What I have here is a relatively simple endpoint for a small site I'm making. Idea is to take:
title
content
tags
and create an entry in the database. It works properly.
I threw this together as ...
2
votes
1
answer
137
views
Python (Flask) - User registration system
I am working on a simple CRUD app as a personal project using Flask. I am currently working on the user service and I just finished the registration process. I am also trying to use as less as ...
3
votes
1
answer
607
views
Python OOP - Web App (Flask) - User registration class?
I am working on a simple CRUD app as a personal project using Flask. I am currently working on the user blueprint and trying to use as less as libraries as I could and no ORM (for learning purposes). ...
0
votes
2
answers
92
views
on using the strategy pattern to switch between database layers
I'd like to build an app in Flask that can switch between talking to a PostGresql and a Mongo DB. As I understand it, the Strategy Pattern is about being able to switch algorithms that are referred ...
3
votes
1
answer
79
views
Flask Database Design with ORM
I am designing a Stock Currency application and for that, I created a database.
I searched for my question here first but the answerer told me to ask the same question here.
...
12
votes
3
answers
150
views
Suggestions on cleaning up Flask app
I've written a little bit of code to pull data out of my FitBit and store it in a GCP database for further analysis. The project is available here, but what I'd like to ask about specifically is the ...
3
votes
1
answer
3k
views
python flask spawn jobs with multiprocessing
I have a python flask app that waits for requests from user app and than spawns a process with job based on the request it receives.
It keeps the status and queue of the jobs in memory.
The requests ...
3
votes
1
answer
52
views
Flask app to return close prices & average
I've been working on a little challenge in order to learn more.. I've written the following code, which works. I'm just concerned that there are several areas where my lack of in depth Python ...
3
votes
1
answer
1k
views
Python Flask, best way for users to update profile details
I have a very standard Flask website being built, more or less straight out of the documentation though am now at a point where I'm going a bit off the book and am probably being highly inefficient ...
6
votes
1
answer
548
views
Air Quality/Environment Monitoring Web App using Plotly Dash
Overview & Motivation
This project manages and displays sensor data (temperature, humidity, Air Quality Index). The sensor data is displayed by the sensor manufacturer, PurpleAir, but their tool ...
1
vote
0
answers
51
views
Improving response time of flask endpoint
The flask endpoint is supposed to take a table name as a parameter, and then return the entire contents of the table as JSON. The table has 200,000 rows and I was wondering if there is any way to ...
2
votes
0
answers
199
views
Simple Flask REST API to a MongoDB
I'm writing a simple REST API to my MongoDB using PyMongo (Python 3.7).
Each collection I have in the DB has a route (e.g http://the.api.url/collection_name ),
and every document under that collection ...
2
votes
3
answers
59
views
Track the existence of process
I have an api endpoint that, when called, initiates the generation of a report. This is time consuming process and response could come pretty late. So, we came up with caching architecture and once ...
4
votes
1
answer
98
views
Weather Forecast Web Application
I've made a Python Flask app and I have some questions about the structure of the main module (equivalent of index.py).
Here is what it looks like:
...
2
votes
0
answers
75
views
Return aggregated values
It's the first time a write a non-trivial mongodb query, and I came up with one that does work, but is 123 lines long! Surely there must be a way to write it in a more concise way.
The purpose of the ...
1
vote
1
answer
166
views
How to make the filtering queries more efficient using flask sqlalchemy?
I have a following table in a flask app
...
2
votes
0
answers
50
views
Basic flask template with sessions
This Flask app, which makes use of SQLAlchemy, a MySQL server which is only reachable via SSH and Flask-Login, is the base on which I want to write an application which has login protected pages.
...
1
vote
0
answers
482
views
Celery tasks and Flask application factory
I am implementing a few Celery background tasks (e.g sending an email, subscribing someone to an Audience via Mailchimp API, etc.) and my project relies on a Flask application factory.
Now, I am ...
1
vote
0
answers
141
views
querying users from table if user.id is found in another table
I am using flask with sqlAlchemy to connect with a postgresql database with two tables
Users table (id, name)
...
4
votes
1
answer
617
views
9X9 Tic Tac Toe variant with frontend in react and backend in python flask_socketio
I (a junior back-end Java dev) decided I wanted to learn some front-end development skills; in particular, I wanted experience with React and websockets. I decided to write an app that would allow for ...
4
votes
0
answers
80
views
Potential Security Threats With Custom Login
I'm looking to find what security flaws this code might have. I believe it's immune to time attacks, passwords are stored encrypted, and I'm using sessions to store local data.
Let's assume the ...
2
votes
0
answers
43
views
Six Nations Prediction league Web App
I built a simple web app to manage my friends and I's six nation prediction league. This is my first go at web development so although it works I am guessing that I am not following all best practices ...
3
votes
1
answer
39
views
A storage bin thingy for Repl.it projects
I have a Repl.it account that I use for my projects, and I don't really want to make a new api for storage every time, I've seen some like EasyDB and Jsonstore (I use Jsonstore in the background as ...
3
votes
0
answers
178
views
Is this a good way to process SQLAlchemy's uniqueness constraint violation in Flask?
I'm using Flask along with Flask-SQLAlchemy and Flask-WTF.
I have a model:
...
3
votes
1
answer
69
views
Jinja2 block that is unreadable [closed]
I have a block of Jinja2 (used in Sceptre/CloudFormation). It is not readable in my opinion, but I can't find any way to clean it up to improve it.
...
1
vote
0
answers
1k
views
Anything Wrong with This Method of API Versioning Using Flask?
I'm trying to find a sensible way to structure a REST API written in Flask. I'm new to writing such things and I've not seen this structure used anywhere else, so before I continue I wanted to ask ...
2
votes
1
answer
127
views
Website for allowing data evaluation from submission
I'm making a really basic website where users essentially just submit data into some forms and they will be able to review their data in another page. I feel like I'm going to be repeating myself far ...
5
votes
0
answers
327
views
what is the correct way to write an endpoint?
Here is a rather large endpoint that I have written in Python using Flask and SQLAlchemy, I was wondering if there are any tips I could get.
The endpoint takes a post request which contains specific ...
5
votes
0
answers
546
views
Docker-compose for task-based Flask API with Redis and rq
I am not a Docker guru or expert in Flask or Redis. However, I need to leverage these technologies. I managed to cobble something together that works and would like to submit it for review.
The MWE ...
6
votes
1
answer
317
views
Flask application for buying stocks
I wrote three Flask views below.
First view
input stock code
Second view
get the stock details (name, price) of the stock by using 3rd party api
get the balance cash of DB and show to the view ...