Use gunicorn instead of Werkzeug and 32 more very minor changes (#35)

This commit is contained in:
Mungai Geoffrey
2022-04-21 03:29:42 +03:00
committed by GitHub
parent 68b474bbba
commit ef68cae625
33 changed files with 751 additions and 227 deletions
+2 -4
View File
@@ -1,7 +1,6 @@
from flask import Flask
from flask_cors import CORS
from flask_caching import Cache
from flask_cors import CORS
config = {"CACHE_TYPE": "SimpleCache", "CACHE_DEFAULT_TIMEOUT": 300}
@@ -19,7 +18,7 @@ def create_app():
cache.init_app(app)
with app.app_context():
from app.api import artist, track, search, folder, album, playlist
from app.api import album, artist, folder, playlist, search, track
app.register_blueprint(album.album_bp, url_prefix="/")
app.register_blueprint(artist.artist_bp, url_prefix="/")
@@ -28,5 +27,4 @@ def create_app():
app.register_blueprint(folder.folder_bp, url_prefix="/")
app.register_blueprint(playlist.playlist_bp, url_prefix="/")
return app
+5 -4
View File
@@ -1,12 +1,13 @@
"""
Contains all the album routes.
"""
from flask import Blueprint, request
from app import api
from app import helpers, cache
from app import functions
from app.lib import albumslib, trackslib
from app import helpers
from app.lib import albumslib
from app.lib import trackslib
from flask import Blueprint
from flask import request
album_bp = Blueprint("album", __name__, url_prefix="")
+6
View File
@@ -4,6 +4,7 @@ This library contains all the functions related to playlists.
import os
import random
import string
from datetime import datetime
from app import api
from app import exceptions
@@ -55,6 +56,7 @@ def create_all_playlists():
playlists = instances.playlist_instance.get_all_playlists()
_bar = Bar("Creating playlists", max=len(playlists))
for playlist in playlists:
api.PLAYLISTS.append(models.Playlist(playlist))
@@ -132,3 +134,7 @@ def validate_images():
for image in os.listdir(p_path):
if image not in images:
os.remove(os.path.join(p_path, image))
def create_new_date():
return datetime.now()
+6 -8
View File
@@ -4,16 +4,17 @@ from datetime import datetime
from app import models
def date_string_to_time_passed(dstring: str) -> str:
def date_string_to_time_passed(prev_date: str) -> str:
"""
Converts a date string to time passed. eg. 2 minutes ago, 1 hour ago, yesterday, 2 days ago, 2 weeks ago, etc.
"""
now = datetime.now()
then = datetime.strptime(dstring, "%Y-%m-%d %H:%M:%S")
then = datetime.strptime(prev_date, "%Y-%m-%d %H:%M:%S")
diff = now - then
days = diff.days
print(days)
if days < 0:
return "in the future"
@@ -32,22 +33,19 @@ def date_string_to_time_passed(dstring: str) -> str:
elif days == 1:
return "yesterday"
elif days < 7:
if days == 1:
return "1 day ago"
return str(days) + " days ago"
elif days < 30:
if days == 7:
if days < 14:
return "1 week ago"
return str(days // 7) + " weeks ago"
elif days < 365:
if days == 30:
if days < 60:
return "1 month ago"
return str(days // 30) + " months ago"
elif days > 365:
if days == 365:
if days < 730:
return "1 year ago"
return str(days // 365) + " years ago"