Questions tagged [flask]

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

Filter by
Sorted by
Tagged with
3
votes
2answers
795 views

Conditionally inserting MySQL entries in a Flask app

I am a newbie in back-end developing. I know that the biggest part of back-end development is interaction with database. I established a connection and the code is 100% working, but I am wondering if ...
3
votes
1answer
2k views

Flask form validation technique

This is currently the code that I'm using to validate and check for errors in a flask app, where the form fields are coming from a /registration html page: ...
3
votes
3answers
930 views

Flask route to pull data from database for getJSON to process

I am developing a reporting application in Flask where I pull data in a route function from a postgresql database and jsonify the data. On the client side I have ...
3
votes
1answer
105 views

Catching API changes for a service that doesn't version its API

I'm using the old Google Data API to access several spreadsheets and put their contents in a database using Flask and SQLAlchemy. Each run deletes the contents of the database tables and repopulates ...
3
votes
1answer
1k views

Slow Flask-SQLAlchemy query using association tables

I have two models in Flask-SQLAlchemy (Post and Comment) that have many-to-many relationship that is manifested in the third model (post_mentions): ...
3
votes
1answer
55 views

Handling Many Unexpected States with except

I am creating a server with Flask and it has quite a few routes. Most routes require a specific state, such as "logged in" or "process started". All of my functions and methods in packages will throw ...
3
votes
1answer
3k views

Applying dynamic filters to a SQL query using Python conditional expressions

I wrote this piece of code to eliminate the need for multiple if then statements based on the filters from the incoming REST request. If the request has category ...
3
votes
1answer
2k views

Python RESTful image handler

This is a view as part of a RESTful image handler module, written for Flask, I am sure there is a better/more pythonic way of doing parts of this, maybe using List Comprehensions or Generator ...
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
2answers
2k views

Utilization of Steam APIs and web-scraping

Some background info here: This is a small fun project I made utilizing Steam APIs and web-scraping This is the first time I've ever used Python, so I'm not very familiar with the language I used ...
2
votes
1answer
64 views

Fetching and displaying the provisioning status of a phone number

I have the following function: ...
2
votes
1answer
30 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. ...
2
votes
1answer
74 views

Extension pattern in a flask controller using importlib 2.0

The first edition of the code can be found in this 1.0 version. To summarize the problem : I have an endpoint in flask where the work logic change according to the query I am trying to implement an ...
2
votes
1answer
162 views

Simple web application for benchmark

There is an article where the author tries to compare performance of different web stacks. The result looks pretty controversial. I try to prove that in real use case the difference between scores of ...
2
votes
1answer
399 views

Python flask web app, simplification [closed]

I am writing web application using flask framework + mongodb. I have an issue, should I use classes for my mongo entities or just use dictionaries for them. ...
2
votes
2answers
237 views

Simple Python Flash app using Wikidot API to transfer pages between two wikis

Here's a simple Python Flask app. It uses the Wikidot API to transfer pages between two wikis. I'd like to hear your input on the best way to refactor this code. Here are a couple of questions I ...
2
votes
3answers
51 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 ...
2
votes
1answer
39 views

REST API stored in a MongoDB Atlas Database

I am building my first REST API using data stored in my MongoDB Atlas Database. I tried to read the REST API conventions with the versioning, using plural nouns for resources and sending the right ...
2
votes
1answer
2k views

Class of file uploading to S3 using boto with multipart supported

I'm writing an app by Flask with a feature to upload large file to S3 and made a class to handle this. I have some targets in writing code: Code must be easy to understand and maintain. (Yes, ...
2
votes
1answer
1k views

Utility Class for CRUD Operations in a Flask App

I'm new to Flask and Python and am trying to sort out the most pythonic way to modularize my utilities. I have models.py which have my sqlalchemy models and ...
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
1answer
34 views

How to make the filtering queries more efficient using flask sqlalchemy?

I have a following table in a flask app ...
1
vote
1answer
130 views

Refresh webpage on change in folder

I want to refresh my web page every time a file is uploaded to the folder. I have a web service written in flask having the following handler ...
1
vote
1answer
690 views

GET and POST with Flask - optimum performance

I have this code to POST and save a digest to redis, and retrieve it from redis on a GET. This uses Python and Flask, of course. ...
1
vote
1answer
458 views

Expiring JWT tokens in Flask

I've been using flask-jwt-extended for my application and one of the problems I had was logging a session out and making sure the token is not usable anymore. I've ...
1
vote
1answer
71 views

Add user to a database and perform relevant checks

Below is a function that adds a new user to the database using their email and password. I am using Flask and SQLAlchemy. ...
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) ...