#!env/bin/python3.10
# -*- coding: UTF-8 -*-

# активация FLASK
from flask import Flask, send_from_directory

from flask import jsonify  # для генерации JSON, не актуально
from flask_cors import CORS

# from flask import redirect, url_for


# Активируем сжатие данных
from flask_compress import Compress
compress = Compress()
app = Flask(__name__, static_url_path='', static_folder='')
compress.init_app(app)


# Статика

@app.route('/favicon.ico')
def favicon():
    return send_from_directory('static/image',
                               'favicon.ico', mimetype='image/vnd.microsoft.icon')


@app.route('/static/<path:path>')
def send_from_statics(path):
    return send_from_directory('static', path)


@app.route('/temp/<path:path>')
def send_from_temp(path):
    return send_from_directory('temp', path)


# enable CORS
CORS(app)

# sanity check route


@app.route('/ping', methods=['GET'])
def ping_pong():
    return jsonify('pong!')

# @app.route('/<path:path>')
# def static_file(path):
#    return app.send_static_file(path)#


# активируем файл конфигурации
app.config.from_object('config')

# активируем Вьювер
from app import views
