Deploy Flask application

Hello everyone! Please help me.
I get a 404 error when deploying Flask on Hestia cp
.htaccess looks like this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$$1 [QSA,L] looks like this:

from flask import Flask, request, jsonify, send_from_directory, url_for
from flask_cors import CORS, cross_origin
from functools import wraps
import database
import os
from werkzeug.utils import secure_filename

app = Flask(__name__, static_folder="build/static")
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'

def check_required_keys(dictionary, keys):
    errors = []
    for key in keys:
        if key not in dictionary:
            errors.append(f"{key} is required")
    return errors

def token_required(func):
    @wraps(func)  # Добавляем декоратор для сохранения имени функции
    def wrapper(*args, **kwargs):
        token = request.headers.get("Authorization")
        if not token:
            return jsonify({"errors": ["Missing token"]}), 401
        if not token.startswith("Bearer "):
            return jsonify({"errors": ["Invalid token type"]}), 401
        # Удаляем префикс Bearer и пробел
        token = token[7:]
        is_token = database.token_exists(token)
        if not is_token:
            return jsonify({"errors": ["Invalid token"]}), 401
        return func(*args, **kwargs)
    return wrapper

@app.route('/', methods=['GET'])
def index():
        return send_from_directory('build', "index.html")
        return "<h1>Страница не найдена</h1>"

@app.route('/api/users', methods=['POST'])
def users():
    data = request.get_json()
    errors = check_required_keys(data, ['name', 'username', 'email', 'password'])
    if len(errors) > 0:
        return jsonify({"errors": errors}), 422
        ok, error = database.register_user(data['name'], data['username'], data['email'], data['password'])
        if ok:
            return jsonify({"message": "User added successfully"}), 201
            return jsonify({"errors": [error]}), 422

@app.route('/api/login', methods=['POST'])
def login():
    data = request.get_json()
    errors = check_required_keys(data, ['login', 'password'])
    if len(errors) > 0:
        return jsonify({"errors": errors}), 422
        token = database.get_token(data['login'], data['password'])
        if token:
            return jsonify({
                "message": "User logged in successfully",
                "token": token
                }), 200
            return jsonify({"errors": ["Invalid login or password"]}), 401

@app.route('/api/profile', methods=['GET'])
def profile():
    user = database.get_user(request.headers.get('Authorization')[7:])
    if user:
        return jsonify({"data": user}), 200
    return jsonify({"errors": ["User not found"]}), 404

@app.route('/api/upload', methods=['POST'])
def upload_file():
    if request.method == 'POST':
        errors = check_required_keys(request.files, ['file'])
        if len(errors) > 0:
            return jsonify({"errors": errors}), 422
        file = request.files['file']
        filename = secure_filename(file.filename)
        file_path = os.path.join('media', filename)
        file_url = url_for('serve_file', filename=filename)
        return jsonify({"data": file_url}), 201
def serve_file(filename):
    return send_from_directory('media', filename)

# Запуск сервера
if __name__ == '__main__':
    if not os.path.exists('media'):


import sys
sys.path.insert(0, '/home/web/')

from server import app as application

I have the following files in home/web/