import os
import re
import atexit
from flask import Flask, request, redirect, render_template, send_from_directory
from apscheduler.schedulers.background import BackgroundScheduler
from werkzeug.utils import secure_filename
from server_utils.file_helper import init_folders, is_valid_file, upload_file, proccess_file_face, proccess_file_disguise, download_file, delete_old_files

app = Flask(__name__,
    template_folder='build',
    static_folder='build/static',
    static_url_path='/build/static'
)
app.config.from_pyfile('server_config.py')

@app.route("/")
def index():
    return render_template('index.html')

@app.route("/about")
def about():
    return render_template('index.html')

@app.route("/face_rec", methods=["GET", "POST"])
def face_rec():
    if request.method == "POST":
        if "file" not in request.files:
            return redirect(request.url)
        
        file = request.files["file"]
        filename = file.filename

        if filename == "":
            return redirect(request.url)
        
        if file and is_valid_file(filename):
            filename = secure_filename(filename)
            upload_file(file, filename)
            proccess_file_face(filename)
            return download_file(filename)
            
    return render_template('index.html')

@app.route("/disguise", methods=["POST"])
def diguise():
    if request.method == "POST":
        if "file" not in request.files:
            return redirect(request.url)
        
        file = request.files["file"]
        filename = file.filename

        if filename == "":
            return redirect(request.url)
        
        if file and is_valid_file(filename):
            filename = secure_filename(filename)
            upload_file(file, filename)
            proccess_file_disguise(filename, style=request.form['option'])
            return download_file(filename)
            
    return render_template('index.html')

# Build files from React
@app.route("/<path:path>")
def send_static(path):
    return send_from_directory('build/', path)

@app.route("/images/<path:path>")
def send_image(path):
    return send_from_directory('build/images', path)

@app.route("/videos/<path:path>")
def send_video(path):
    return send_from_directory('build/videos', path)

@app.route("/static/js/<path:path>")
def send_static_js(path):
    return send_from_directory('build/static/js', path)

@app.route("/static/css/<path:path>")
def send_static_css(path):
    return send_from_directory('build/static/css', path)


scheduler = BackgroundScheduler()
scheduler.add_job(func=delete_old_files, trigger="interval", seconds=120)
scheduler.start()
atexit.register(lambda: scheduler.shutdown())

# Main
if __name__ == "__main__":
    init_folders()
    app.run()
406477a0faecda89faf490d8e0d2c2e264f2d0d8
<mask token>


@app.route('/about')
def about():
    return render_template('index.html')


@app.route('/face_rec', methods=['GET', 'POST'])
def face_rec():
    if request.method == 'POST':
        if 'file' not in request.files:
            return redirect(request.url)
        file = request.files['file']
        filename = file.filename
        if filename == '':
            return redirect(request.url)
        if file and is_valid_file(filename):
            filename = secure_filename(filename)
            upload_file(file, filename)
            proccess_file_face(filename)
            return download_file(filename)
    return render_template('index.html')


<mask token>


@app.route('/images/<path:path>')
def send_image(path):
    return send_from_directory('build/images', path)


<mask token>


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


<mask token>

<mask token>


@app.route('/about')
def about():
    return render_template('index.html')


@app.route('/face_rec', methods=['GET', 'POST'])
def face_rec():
    if request.method == 'POST':
        if 'file' not in request.files:
            return redirect(request.url)
        file = request.files['file']
        filename = file.filename
        if filename == '':
            return redirect(request.url)
        if file and is_valid_file(filename):
            filename = secure_filename(filename)
            upload_file(file, filename)
            proccess_file_face(filename)
            return download_file(filename)
    return render_template('index.html')


@app.route('/disguise', methods=['POST'])
def diguise():
    if request.method == 'POST':
        if 'file' not in request.files:
            return redirect(request.url)
        file = request.files['file']
        filename = file.filename
        if filename == '':
            return redirect(request.url)
        if file and is_valid_file(filename):
            filename = secure_filename(filename)
            upload_file(file, filename)
            proccess_file_disguise(filename, style=request.form['option'])
            return download_file(filename)
    return render_template('index.html')


<mask token>


@app.route('/images/<path:path>')
def send_image(path):
    return send_from_directory('build/images', path)


@app.route('/videos/<path:path>')
def send_video(path):
    return send_from_directory('build/videos', path)


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


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


<mask token>

<mask token>


@app.route('/')
def index():
    return render_template('index.html')


@app.route('/about')
def about():
    return render_template('index.html')


@app.route('/face_rec', methods=['GET', 'POST'])
def face_rec():
    if request.method == 'POST':
        if 'file' not in request.files:
            return redirect(request.url)
        file = request.files['file']
        filename = file.filename
        if filename == '':
            return redirect(request.url)
        if file and is_valid_file(filename):
            filename = secure_filename(filename)
            upload_file(file, filename)
            proccess_file_face(filename)
            return download_file(filename)
    return render_template('index.html')


@app.route('/disguise', methods=['POST'])
def diguise():
    if request.method == 'POST':
        if 'file' not in request.files:
            return redirect(request.url)
        file = request.files['file']
        filename = file.filename
        if filename == '':
            return redirect(request.url)
        if file and is_valid_file(filename):
            filename = secure_filename(filename)
            upload_file(file, filename)
            proccess_file_disguise(filename, style=request.form['option'])
            return download_file(filename)
    return render_template('index.html')


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


@app.route('/images/<path:path>')
def send_image(path):
    return send_from_directory('build/images', path)


@app.route('/videos/<path:path>')
def send_video(path):
    return send_from_directory('build/videos', path)


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


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


<mask token>

import os
import re
import atexit
from flask import Flask, request, redirect, render_template, send_from_directory
from apscheduler.schedulers.background import BackgroundScheduler
from werkzeug.utils import secure_filename
from server_utils.file_helper import init_folders, is_valid_file, upload_file, proccess_file_face, proccess_file_disguise, download_file, delete_old_files
app = Flask(__name__, template_folder='build', static_folder='build/static',
    static_url_path='/build/static')
app.config.from_pyfile('server_config.py')


@app.route('/')
def index():
    return render_template('index.html')


@app.route('/about')
def about():
    return render_template('index.html')


@app.route('/face_rec', methods=['GET', 'POST'])
def face_rec():
    if request.method == 'POST':
        if 'file' not in request.files:
            return redirect(request.url)
        file = request.files['file']
        filename = file.filename
        if filename == '':
            return redirect(request.url)
        if file and is_valid_file(filename):
            filename = secure_filename(filename)
            upload_file(file, filename)
            proccess_file_face(filename)
            return download_file(filename)
    return render_template('index.html')


@app.route('/disguise', methods=['POST'])
def diguise():
    if request.method == 'POST':
        if 'file' not in request.files:
            return redirect(request.url)
        file = request.files['file']
        filename = file.filename
        if filename == '':
            return redirect(request.url)
        if file and is_valid_file(filename):
            filename = secure_filename(filename)
            upload_file(file, filename)
            proccess_file_disguise(filename, style=request.form['option'])
            return download_file(filename)
    return render_template('index.html')


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


@app.route('/images/<path:path>')
def send_image(path):
    return send_from_directory('build/images', path)


@app.route('/videos/<path:path>')
def send_video(path):
    return send_from_directory('build/videos', path)


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


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


scheduler = BackgroundScheduler()
scheduler.add_job(func=delete_old_files, trigger='interval', seconds=120)
scheduler.start()
atexit.register(lambda : scheduler.shutdown())
if __name__ == '__main__':
    init_folders()
    app.run()

import os
import re
import atexit
from flask import Flask, request, redirect, render_template, send_from_directory
from apscheduler.schedulers.background import BackgroundScheduler
from werkzeug.utils import secure_filename
from server_utils.file_helper import init_folders, is_valid_file, upload_file, proccess_file_face, proccess_file_disguise, download_file, delete_old_files

app = Flask(__name__,
    template_folder='build',
    static_folder='build/static',
    static_url_path='/build/static'
)
app.config.from_pyfile('server_config.py')

@app.route("/")
def index():
    return render_template('index.html')

@app.route("/about")
def about():
    return render_template('index.html')

@app.route("/face_rec", methods=["GET", "POST"])
def face_rec():
    if request.method == "POST":
        if "file" not in request.files:
            return redirect(request.url)
        
        file = request.files["file"]
        filename = file.filename

        if filename == "":
            return redirect(request.url)
        
        if file and is_valid_file(filename):
            filename = secure_filename(filename)
            upload_file(file, filename)
            proccess_file_face(filename)
            return download_file(filename)
            
    return render_template('index.html')

@app.route("/disguise", methods=["POST"])
def diguise():
    if request.method == "POST":
        if "file" not in request.files:
            return redirect(request.url)
        
        file = request.files["file"]
        filename = file.filename

        if filename == "":
            return redirect(request.url)
        
        if file and is_valid_file(filename):
            filename = secure_filename(filename)
            upload_file(file, filename)
            proccess_file_disguise(filename, style=request.form['option'])
            return download_file(filename)
            
    return render_template('index.html')

# Build files from React
@app.route("/<path:path>")
def send_static(path):
    return send_from_directory('build/', path)

@app.route("/images/<path:path>")
def send_image(path):
    return send_from_directory('build/images', path)

@app.route("/videos/<path:path>")
def send_video(path):
    return send_from_directory('build/videos', path)

@app.route("/static/js/<path:path>")
def send_static_js(path):
    return send_from_directory('build/static/js', path)

@app.route("/static/css/<path:path>")
def send_static_css(path):
    return send_from_directory('build/static/css', path)


scheduler = BackgroundScheduler()
scheduler.add_job(func=delete_old_files, trigger="interval", seconds=120)
scheduler.start()
atexit.register(lambda: scheduler.shutdown())

# Main
if __name__ == "__main__":
    init_folders()
    app.run()