Reformat python code via black
This commit is contained in:
parent
0ada059a22
commit
d0c45a6a62
8 changed files with 44 additions and 28 deletions
|
@ -1,5 +1,14 @@
|
|||
import os
|
||||
from flask import Flask, render_template, request, jsonify, redirect, url_for, current_app, send_file
|
||||
from flask import (
|
||||
Flask,
|
||||
render_template,
|
||||
request,
|
||||
jsonify,
|
||||
redirect,
|
||||
url_for,
|
||||
current_app,
|
||||
send_file,
|
||||
)
|
||||
from flask_caching import Cache
|
||||
|
||||
from toloka2MediaServer.main_logic import (
|
||||
|
@ -12,13 +21,13 @@ from toloka2MediaServer.main_logic import (
|
|||
)
|
||||
from app.services.torrents import initiate_config, serialize_operation_result
|
||||
|
||||
#from .api import api_bp
|
||||
# from .api import api_bp
|
||||
from .client import client_bp
|
||||
from .api import *
|
||||
from .db import db
|
||||
|
||||
# App
|
||||
app = Flask(__name__, static_folder='../frontend/dist/assets')
|
||||
app = Flask(__name__, static_folder="../frontend/dist/assets")
|
||||
app.register_blueprint(client_bp)
|
||||
app.register_blueprint(api_bp)
|
||||
|
||||
|
@ -35,10 +44,12 @@ with app.app_context():
|
|||
|
||||
# Production route
|
||||
from .config import Config
|
||||
app.logger.info('>>> {}'.format(Config.FLASK_ENV))
|
||||
|
||||
@app.route('/')
|
||||
app.logger.info(">>> {}".format(Config.FLASK_ENV))
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def index_client():
|
||||
dist_dir = current_app.config['DIST_DIR']
|
||||
entry = os.path.join(dist_dir, 'index.html')
|
||||
dist_dir = current_app.config["DIST_DIR"]
|
||||
entry = os.path.join(dist_dir, "index.html")
|
||||
return send_file(entry)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from flask import Blueprint
|
||||
|
||||
api_bp = Blueprint('api', __name__)
|
||||
api_bp = Blueprint("api", __name__)
|
||||
|
||||
from .titles import *
|
||||
from .toloka import *
|
||||
|
|
|
@ -2,6 +2,7 @@ from flask import jsonify
|
|||
from app.services.torrents import initiate_config
|
||||
from . import api_bp
|
||||
|
||||
|
||||
@api_bp.route("/api/config/")
|
||||
def config_route():
|
||||
config = initiate_config()
|
||||
|
|
|
@ -50,14 +50,15 @@ def titles_route():
|
|||
|
||||
return jsonify(sections)
|
||||
|
||||
@api_bp.route("/api/add", methods=['POST'])
|
||||
|
||||
@api_bp.route("/api/add", methods=["POST"])
|
||||
def add_route():
|
||||
config = initiate_config()
|
||||
|
||||
requestData = RequestData(
|
||||
url=request.json["tolokaUrl"],
|
||||
season=request.json["seasonIndex"],
|
||||
index=int(request.json["episodeIndex"].split('.')[0]),
|
||||
index=int(request.json["episodeIndex"].split(".")[0]),
|
||||
correction=int(request.json["adjustedEpisodeNumber"]),
|
||||
title=request.json["dirname"],
|
||||
)
|
||||
|
@ -99,6 +100,3 @@ def update_route(codename):
|
|||
except Exception as e:
|
||||
message = f"Error: {str(e)}"
|
||||
return {"error": message}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@ from flask import jsonify
|
|||
from app.services.torrents import initiate_config
|
||||
from . import api_bp
|
||||
|
||||
|
||||
@api_bp.route("/api/toloka/<id>")
|
||||
def toloka_torrent_route(id):
|
||||
config = initiate_config()
|
||||
return jsonify(config.toloka.get_torrent('https://toloka.to/' + id))
|
||||
return jsonify(config.toloka.get_torrent("https://toloka.to/" + id))
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
import os
|
||||
from flask import Blueprint, render_template
|
||||
|
||||
client_bp = Blueprint('client_app', __name__,
|
||||
static_folder='../frontend/dist/assets/',
|
||||
template_folder='../frontend/dist/',
|
||||
)
|
||||
client_bp = Blueprint(
|
||||
"client_app",
|
||||
__name__,
|
||||
static_folder="../frontend/dist/assets/",
|
||||
template_folder="../frontend/dist/",
|
||||
)
|
||||
|
|
|
@ -7,18 +7,19 @@ See `.flaskenv` for default settings.
|
|||
import os
|
||||
from app import app
|
||||
|
||||
|
||||
class Config(object):
|
||||
# If not set fall back to production for safety
|
||||
FLASK_ENV = os.getenv('FLASK_ENV', 'production')
|
||||
FLASK_ENV = os.getenv("FLASK_ENV", "production")
|
||||
# Set FLASK_SECRET on your production Environment
|
||||
SECRET_KEY = os.getenv('FLASK_SECRET', 'Secret')
|
||||
SECRET_KEY = os.getenv("FLASK_SECRET", "Secret")
|
||||
|
||||
APP_DIR = os.path.dirname(__file__)
|
||||
ROOT_DIR = os.path.dirname(APP_DIR)
|
||||
DIST_DIR = os.path.join(ROOT_DIR, 'frontend/dist')
|
||||
DIST_DIR = os.path.join(ROOT_DIR, "frontend/dist")
|
||||
|
||||
if not os.path.exists(DIST_DIR):
|
||||
raise Exception(
|
||||
'DIST_DIR not found: {}'.format(DIST_DIR))
|
||||
raise Exception("DIST_DIR not found: {}".format(DIST_DIR))
|
||||
|
||||
app.config.from_object('app.config.Config')
|
||||
|
||||
app.config.from_object("app.config.Config")
|
||||
|
|
|
@ -4,9 +4,11 @@ from sqlalchemy.orm import DeclarativeBase, MappedAsDataclass
|
|||
|
||||
db = SQLAlchemy()
|
||||
|
||||
|
||||
class Base(DeclarativeBase, MappedAsDataclass):
|
||||
pass
|
||||
|
||||
|
||||
class ImagesCache(Base):
|
||||
__tablename__ = "image_cache"
|
||||
|
||||
|
|
Loading…
Reference in a new issue