14 votes
Accepted

Raspberry PI controllable Christmas Tree

I would suggest to separate the concerns of coloring and animating. Now, in particular theater_chase_rainbow duplicates code from other methods. Instead, have ...
Janne Karila's user avatar
  • 10.3k
8 votes
Accepted

Trending Machine Learning topics for Alexa

Structure Nothing! The code seems fairly straightforward and clear, and I was able to understand what you’re doing even if I didn't study flask too much. So I don’t think there’s anything wrong with ...
Grajdeanu Alex's user avatar
8 votes
Accepted

Python/Flask Password Manager

Disclaimer: I haven't done authentication in Flask before. Tl;dr: Don't do authentication yourself, it's VERY hard to do right (and using a global ain't right); also, separate the user's ...
scnerd's user avatar
  • 2,030
6 votes
Accepted

Python function to implement an image-processing pipeline

As Reinderien mentions, you can decrease some of the complexity of your code by inverting your if-statements. While I cannot test this because I do not have your whole code, here is how it could be ...
esote's user avatar
  • 3,770
5 votes

Trending Machine Learning topics for Alexa

You could break your main function into multiple functions. Doing that will not even make main() much more clearer but also you ...
Ashwini Chaudhary's user avatar
5 votes

A simple library using Flask and SQLAlchemy

Document with docstrings. Your functions and ORM models are currently not providing any useful documentation regarding their respective function within your program. Don't initialize the database on ...
Richard Neumann's user avatar
5 votes
Accepted

URL shortener using Flask

I do have a few comments: Handling Non-Unique Digests It's good that you recognize that digests such as MD5 are not guaranteed to be unique. But, although you have ...
Booboo's user avatar
  • 1,636
4 votes
Accepted

Authentication for a Flask API

Building on @Drewverlee's answer, I would consider renaming BaseException to APIException, or something of the like. Also, I ...
Tex Andersen's user avatar
4 votes
Accepted

Authenticating an internal API with Flask

Just because you don't have many people using this API now, this does not mean that this will always be the case. In addition, you might want to discriminate between the users of the API for various ...
Graipher's user avatar
  • 41k
4 votes

Python Flask, best way for users to update profile details

At the least, this can be done more efficiently: ...
Reinderien's user avatar
3 votes
Accepted

Getting prices of crypto coins

Well, I shall start from the top. According to the style guide, PEP 8 imports should be in the following order: standard library imports related third party imports local application/...
Walid Mujahid وليد مجاهد's user avatar
3 votes
Accepted

Fetching Python news headlines for Alexa

You probably want to move the session to a global variable(or simply use requests.get) else at function level it is not helping in re-using any connections right ...
Ashwini Chaudhary's user avatar
3 votes

RESTful APIs (Create, Read) with flask-restful

The MongoClient was designed to be instantiated once per app life cycle, so this is redundant. You should try to reuse ...
Artem's user avatar
  • 281
3 votes
Accepted

Flask brand API endpoint unit test

Move the os.environ and sys.path calls into a new setUpClass method instead of have them at ...
ferada's user avatar
  • 11.1k
3 votes
Accepted

SQLite database for a micro/tumble blog application

Everything is good by this point but I'd change the relation between posts and tags from one-to-many to many-to-many. You can do this with this code: ...
Montreal's user avatar
  • 245
3 votes
Accepted

Flask Framework - user sign in

There are a few things bothering me in one version or an other: the error=error or None is unnecessary as error is either ...
301_Moved_Permanently's user avatar
3 votes
Accepted

Blog with Python/Flask

Date formatting self.date_created = f"{now.month}/{now.day}/{now.year} {now.hour}:{now.minute}:{now.second} {end}" should be ...
Reinderien's user avatar
3 votes
Accepted

A storage bin thingy for Repl.it projects

Few optimization tips verify_password function avoid bare except: clause - at least use ...
RomanPerekhrest's user avatar
3 votes

Weather Forecast Web Application

URL URL components should generally appear from "broadest to narrowest" left-to-right. I'm not totally convinced that this is currently the case - the weather site is probably "broader&...
Reinderien's user avatar
3 votes

on using the strategy pattern to switch between database layers

Typically you'd have two classes that implement the four methods create, read, update and delete, one for Mongo and one for ...
nullTerminator's user avatar
3 votes
Accepted

on using the strategy pattern to switch between database layers

The short answer is: You don't need the strategy pattern here. just do as nullTermiator said in his answer. To understand why strategy does not fit here, first we need to understand the problem ...
Mostafa Kashwaa's user avatar
3 votes
Accepted

Python Rubiks cube solver - general code comments

You should put your Configure Memcache section into a function to clean up the global namespace, even if you unconditionally call it from the global namespace. ...
Reinderien's user avatar
3 votes
Accepted

Read and display JSON results from Google Books API

Split search() up into two functions, each accepting only one method, and dispose of your if. There's a little bit of religion ...
Reinderien's user avatar
3 votes

URL shortener using Flask

organize imports from flask import ... import hashlib PEP-8 asks that you organize your imports in three sections. As written, ...
J_H's user avatar
  • 25.1k
3 votes

URL shortener using Flask

At this time, there is no data persistence. If you used a database, then each record would have its own incremented ID, and you could use the ID as an element of "uniqueness" to derive the ...
Kate's user avatar
  • 6,550
2 votes

Mail utility class for use with Flask

I'd unify both functions and only have the bulk/multiple-emails version because the single case is basically a specialisation of the general case and the slight bit more work is unlikely to be ...
ferada's user avatar
  • 11.1k
2 votes
Accepted

RESTful APIs (Create, Read) with flask-restful

Ad. 1 & 2: There is no need to open fresh connection for, and close it after request. MongoClient has connection-pooling built in, so only thing you need to do ...
potfur's user avatar
  • 186
2 votes

Saving temporary file for plotting audio waveform

Instead of saving file you can create io.BytesIO object and use it instead of file. Also ...
user1685095's user avatar
2 votes
Accepted

GET and POST with Flask - optimum performance

You can avoid the Content-Type check by using request.get_json() method. ...
Ashwini Chaudhary's user avatar
2 votes

Refresh webpage on change in folder

Server side: There's no point in importing os and glob inside the function. Local import is used for very specific cases and ...
Tom's user avatar
  • 191

Only top scored, non community-wiki answers of a minimum length are eligible