0.1.9s
This commit is contained in:
@@ -6,7 +6,7 @@ from pathlib import Path
|
||||
|
||||
import requests
|
||||
from flask import (Flask, jsonify, render_template, render_template_string,
|
||||
request, send_from_directory, make_response)
|
||||
request, send_from_directory, make_response, send_file)
|
||||
|
||||
from system_module import db, gelbooru, image_processor, logger, tasks
|
||||
|
||||
@@ -26,12 +26,13 @@ GB_HEADERS = CONFIG_ROOT["gb"]["headers"]
|
||||
FILE_FOLDERS = CONFIG_ROOT["file"]["repos"]
|
||||
FILE_DW_FOLDERS = CONFIG_ROOT["file"]["dw"]
|
||||
THUMB_FOLDER = CONFIG_ROOT["file"]["thumb"]
|
||||
DATA_FOLDER = CONFIG_ROOT["file"]["data"]
|
||||
|
||||
|
||||
gb = gelbooru.GB(GB_ID, GB_HASH, GB_HEADERS, FILE_DW_FOLDERS)
|
||||
log = logger.Logger()
|
||||
log.init_global_exception_hook()
|
||||
database = db.DB(True)
|
||||
database = db.DB(DATA_FOLDER)
|
||||
app = Flask(__name__)
|
||||
|
||||
if not image_processor.check_ffmpeg(): print("WARNING!\n\nУ вас не установлен ffmpeg. Генерация превью для видео не доступна!")
|
||||
@@ -54,7 +55,7 @@ def post(post_id):
|
||||
|
||||
@app.route('/file/<path:filename>')
|
||||
def serve_image(filename):
|
||||
folder_path = task.find_file(filename, FILE_FOLDERS)
|
||||
folder_path = tasks.find_file(filename, FILE_FOLDERS)
|
||||
if folder_path == None:
|
||||
return make_response("Not found", 404)
|
||||
else:
|
||||
@@ -91,6 +92,8 @@ def api():
|
||||
post_id = data["post_id"]
|
||||
result_post = database.get_from_id(post_id)
|
||||
return jsonify(result_post)
|
||||
elif data["type"] == "analytic":
|
||||
return send_file(os.path.join(DATA_FOLDER, "analytic.json"), mimetype="application/json")
|
||||
elif data["type"] == "task":
|
||||
if data["task"] == "analytic":
|
||||
if tasks.calculate_analytic(database, CONFIG_ROOT):
|
||||
|
||||
Reference in New Issue
Block a user