Questions tagged [flask]

Flask is a micro-framework for Python based on Werkzeug, Jinja 2 and good intentions.

47 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
9
votes
0answers
1k views

Flask view dependency injection

I've been into trying to have an as simple as possible dependency container in Python and with your help managed to conceive TinyDIC, many thanks. Now, I use Flask for my apps, and from by background ...
6
votes
0answers
2k views

Improving the Flask cache decorator

In my rumblings developing flask applications I found the caching decorator. The decorator is a short and well-written piece of code, but I feel like it misses the few points bellow: It only caches ...
5
votes
0answers
273 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
0answers
193 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 ...
5
votes
0answers
58 views

Building a form for rebooting many network devices

I have several IP based devices that, due to building maintenance, occasionally lose their communication with the other devices. Normally you'd have to find the device IP, go to its control page and ...
4
votes
0answers
73 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 ...
4
votes
0answers
38 views

Form deserializer for Python Flask

I've started working on a small Flask project for no real reason other than fun, and pulled myself back on form validation. I realize that there are existing libraries like WTForms, but wanted to try ...
4
votes
0answers
2k views

REST API with flask structure and implementation approach

I recently started writing REST API, I wanted to have a proper structure of project and an approach which is more readable and make more sense interms of organising in a logical order. I took ...
3
votes
0answers
143 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
0answers
76 views

Sending push notifications to a user

I have a function whose responsibility is to send a push notification to a user. I call this function from a view in flask framework. I have read multiple articles around refactoring and good designs ...
3
votes
0answers
291 views

Flask-SQLAlchemy model structure

I'm seeking a review of my Flask-SQLAlchemy model structure, particularly adherence to DB best practices, such as avoiding duplication, etc. The models represent the relations between Departments, ...
3
votes
0answers
257 views

My live monitoring web app (Flask, guicorne, heroku, and redis) is spamming the source website

As a student, I am working on a project where I need to forward data from an already existing website to a new one, with the data presented in a different manner. In order to do so with my mediocre ...
3
votes
0answers
835 views

Compressed static file serving in flask

Flask comes with built-in static file serving, but compression support is completely missing. I think the way whitenoise implements it and compress files during builds. The following should serve the ...
3
votes
0answers
919 views

Flask site that uses x-editable to edit elements and update mysql db

This code is built in flask, it allows a user to edit a title and a description of a div. I have used the X-editable library which allows a user to edit text and use ajax requests. I also process ...
3
votes
0answers
2k views

Validating HMAC-SHA256 signature in Python

I am trying to implement HMAC-SHA256 authentication into my Python RESTful API project. I am using Python Eve (built on top of Flask), started with an simplified HMAC-SHA1 example. My application is ...
3
votes
0answers
1k views

Simple Payment System Flask App

Can I please get some reviews and suggestions? This is what this app does: It picks user login from Users table and compare it with the post in the login ...
3
votes
0answers
250 views

Implementing Flask create_app function with SqlAlchemy

I have a simple Flask app that realises rest-api with SQLAlchemy. I have written this create_app function: views.py ...
3
votes
0answers
349 views

Providing a daily feed of current segmented customer data for targeted email campaigns

I just started with Python a month ago, and with Flask this week. This is my first project. I am curious about general style, proper use of Python idioms, and Flask best-practices. run.py: ...
2
votes
0answers
50 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
0answers
73 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 ...
2
votes
0answers
36 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. ...
2
votes
0answers
37 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 ...
2
votes
0answers
601 views

Generate dynamic surveys using Python Flask

I'm building a web app using Flask to offer surveys to users. The number of questions on the survey and the type of questions isn't known until runtime. I finally have the code working properly, and ...
2
votes
0answers
180 views

Flask app to administrate network interfaces

I made a Flask app that consists of 3 pages. Index: Indexes to the 2 pages SubnetOverview: SSH's into the server and executes ifconfig, then returns the output to ...
2
votes
0answers
996 views

Flask-PyMongo best practices to manage a mongodb database using python

The functions below are from a class of slave function which interact with my mongo database. The purpose is to serve a Flask based API by responding with the appropriate data required along with the ...
2
votes
0answers
238 views

Wrapping a web scraper in a RESTful API

The problem I am looking to solve is wrapping a web scraper in a RESTful API such that it can be called programmatically from another application, frontend or microservice. The overall goal is that ...
2
votes
0answers
129 views

Flask WebServer To Test Login

I wrote a small webserver using flask and python to test the response of a program. When the user try to login the program sends to the server a xml file with the data and if everything works, returns ...
2
votes
0answers
124 views

REST backend app script for doing CRUD transactions

As a side project, I am working on Tiddly which is a simple Python(Flask) based app for a generic REST backend that could be used for CRUD transactions on any kind of database (using ...
2
votes
0answers
772 views

Online Snake v0.1 with Python-flask and socketio

What I am essentially doing is writing a snake game that everybody could play on the internet, broadcast their game if they like and so on. Now it looks like this, just websocket-based snake, no user ...
2
votes
0answers
770 views

Using Flask-SocketIO in conjunction with Flask-WTF / WTForms to provide realtime form validation feedback

I am working on a user login using Flask and the following extensions: Flask-Login, Flask-WTF, ...
2
votes
0answers
1k views

Jinja template with Flask

I have this code querying for some objects from my database with Flask-SQLAlchemy: areas = Area.query.all() subareas = Subarea.query.all() And then I use it on ...
2
votes
0answers
447 views

Structure of database model for a Flask project

I'm working on a project with Flask and I'm trying to follow Miguel Grinberg's Flask tutorial as closely as possible while creating what I need for my own project. Overall, how does it look? Miguel's ...
1
vote
0answers
57 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
0answers
24 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) ...
1
vote
0answers
364 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 ...
1
vote
1answer
67 views
1
vote
0answers
844 views

Flask app for control TCP server

This snippet allows to up and down TCP server via Flask endpoints. I'm seriously concerned about global variables here. And asking for review this code. The main idea is to be able to up/down TCP ...
1
vote
0answers
22 views

Deletion button on a website that enforces database integrity

I am designing a website on which users can configure (CRUD) various objects which are mutually dependent upon other types. I am preventing a cascade delete, so let's say a ...
1
vote
0answers
382 views

Log visitor info like latitude, longitude to a database

I am collecting each visitor information like ip, lat, longitude, referrer and language and save it into db, then in db I have column in table with counter that increment if user revisits the web site ...
1
vote
0answers
38 views

API separate request vs logic

Is it a good practice to separate Logic from Request controller in an Api ? Without separation: ...
1
vote
0answers
815 views

Python - Flask Middleware - Request Session Management Strategy

I am trying to determine what the most appropriate strategy for session management and authentication is for a middleware application which acts to receive a request, send it over to a database, and ...
1
vote
0answers
797 views

Parse query filter expression from request URL

I am building a backend APi for which I need to extract query filters from request URL of following pattern: ...
1
vote
0answers
520 views

Alternative session token implementation in flask

Here is my implementation of an alternative session token. The idea is to reset session_token every time get_id is called, so (I ...
1
vote
0answers
369 views

Run a potentially long running application from within a Python webserver and return different results depending on whether the application finishes

I want an API on a Flask/Gunicorn webserver to make a call to a separate, potentially long-running java application. If the java application finishes before the Gunicorn timeout, Flask should return ...
1
vote
0answers
260 views

Flask json rpc2.0 extension

I created a simple extension to handle JSON RPC 2.0 requests on flask I would like some feedback regarding usage here is an usage example: ...
0
votes
0answers
45 views

Inserting data from client-side to MySQL via Flask-Sqlalchemy

I am creating a Bill of Materials (BOM) web app with flask as a backend. As a part of this app I am inserting data into BomStructure table from ...
0
votes
0answers
128 views

Dynamically configurable ZMQ filter with Flask API

I have a stream of ZMQ messages, I need to filter the right ones and save them in MongoDB. The trick is to have an option to set the filter conditions dynamically. I have come up with this solution ...