Questions tagged [flask]

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

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 ...
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 ...
12
votes
2answers
4k views

A website status monitor in Python/Flask

I've written a basic website status checker in Python/Flask which reads a list of URLs from a json file and cycles through them every x seconds to check they're online. It displays the results as a ...
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 ...
4
votes
1answer
57 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
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 ...
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 ...
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. ...
1
vote
0answers
53 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) ...
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 ...
4
votes
1answer
116 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
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 ...
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 ...
3
votes
1answer
34 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
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: ...
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. ...
1
vote
0answers
353 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 ...
5
votes
0answers
271 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
1answer
1k views

Is this implementation for token based authentication in flask-peewee secure and efficient?

I'm making an app with a Flask API backend using a Flask-Peewee ORM and an AngularJS frontend. The Flask-Peewee ORM doesn't support token based authentication, so I decided to try to implement this ...
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 ...
0
votes
0answers
29 views

buying stock module - nonlocal vs global variable or others? [duplicate]

[Background explain] I wrote three Flask views and module interact with the views. I do this one module called /buy using different scenario cases based on flag. Zero view if user come in GET, ...
6
votes
1answer
109 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 ...
7
votes
3answers
112 views

Blog with Python/Flask

I've written a blog site using python and Flask. It works a little like Reddit, but instead of having some anonymous users, ...
6
votes
1answer
561 views

Python/Flask Password Manager

As a project to better my skills in Python, I wrote a password manager. It's a website that has user login/logout functionality, the ability to add websites and passwords, and displays the websites/...
8
votes
2answers
262 views

Trending Machine Learning topics for Alexa

I've created a small Flash Briefing Alexa skill that reports the top 5 trending topics in Machine Learning from the My Bridge service. The feed for the Flash Briefing skill can be pointed to an ...
7
votes
1answer
341 views

Getting prices of crypto coins

I have been working on this Raspberry Pi project for a while. It uses the Poloniex API to get prices of crypto coins and it shows the prices on multiple OLED displays. The displays use different i2c ...
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 ...
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
1answer
61 views

Account automation through Python (with Flask) and javascript

This is my first time doing a code review so I expect a ton of criticism on this from all you professionals. What am I doing? I'm using python with flask to create a service for my web server. My web ...
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 ...
1
vote
0answers
27 views

Safely log-in and save login info into session [closed]

I would like to ask if this code is safe for user to log-in (save ID to session) and check if user is log-in when visiting site (Dashboard). ...
5
votes
1answer
513 views

Authenticating an internal API with Flask

I'm developing an internal API using Flask, although due to limitations with our platform the endpoints will be accessible over the public internet. It will only have a very small number of users and ...
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 ...
2
votes
0answers
593 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 ...
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 ...
0
votes
2answers
3k views

Simple web based file browser with Flask

I made a simple web-based file browser with Flask. It also shows some metadata of a file. I have a few questions regarding security though. Is it possible for an attacker to escape out of the preset ...
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 ...
2
votes
0answers
179 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 ...
4
votes
1answer
105 views

Python Flask website

I'm new to programming and in back-end. Right now I'm trying to learn flask, so I wrote a very simple website that currently encrypts and decrypts the message using RSA and DES. I feel like my app....
2
votes
0answers
237 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 ...
22
votes
1answer
354 views

Raspberry PI controllable Christmas Tree

After having the scales, thermometer and a coffeemaker connected to the internet, it is finally time for Christmas Tree to become smarter. Hardware 6ft Christmas Tree An addressable WS2811 LED strip (...
1
vote
1answer
456 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
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 ...
2
votes
0answers
990 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 ...
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
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): ...
7
votes
2answers
1k views

A simple library using Flask and SQLAlchemy

This is the main.py script that does most of the work of Adding movies (Movie objects) as well as modifying and removing: ...
8
votes
1answer
44k views

Simple login system using Python Flask and MySQL

I've made a login page using Python Flask which works with MySQL. I started learning Flask 2 days ago and it was fun, so I came up with this: ...