<commit_before>#!/usr/bin/python3

import flask
import os
from PIL import Image, ImageFilter

app = flask.Flask(__name__)


def thumbnails(img_dir, thumb_dir):
    os.chdir('/srv/AutoGalleryIndex')
    if not os.path.exists(thumb_dir):
        os.mkdir(thumb_dir)
    image_types = ('.png', '.jpeg', '.jpg', '.bmp', '.tiff', '.tff')
    for file_name in os.listdir(img_dir):
        abs_path = '%s/%s' % (img_dir, file_name)
        
        if '._thumbnails' == file_name:
            continue
        
        if os.path.isdir(abs_path):
            thumbnails(abs_path, '%s/%s' % (thumb_dir, file_name))
            continue
            
        # Super inteligent file type detection
        if os.path.splitext(file_name)[-1].lower() not in image_types:
            continue  # Don't thumbnail non images (duh)
        
        thumb_dest = '%s/%s' % (thumb_dir, file_name)
        #if not os.path.exists(thumb_dest):
        thumb = Image.open(abs_path).resize((100, 178), Image.ANTIALIAS).filter(ImageFilter.DETAIL)
        thumb.save(thumb_dest)


@app.route('/<path:subfolder>')
def gallery(subfolder):
    DOCROOT = '/var/www'<commit_msg>Fix process on every request<commit_after>#!/usr/bin/python3

import flask
import os
from PIL import Image, ImageFilter

app = flask.Flask(__name__)


def thumbnails(img_dir, thumb_dir):
    os.chdir('/srv/AutoGalleryIndex')
    if not os.path.exists(thumb_dir):
        os.mkdir(thumb_dir)
    image_types = ('.png', '.jpeg', '.jpg', '.bmp', '.tiff', '.tff')
    for file_name in os.listdir(img_dir):
        abs_path = '%s/%s' % (img_dir, file_name)
        
        if '._thumbnails' == file_name:
            continue
        
        if os.path.isdir(abs_path):
            thumbnails(abs_path, '%s/%s' % (thumb_dir, file_name))
            continue
            
        # Super inteligent file type detection
        if os.path.splitext(file_name)[-1].lower() not in image_types:
            continue  # Don't thumbnail non images (duh)
        
        thumb_dest = '%s/%s' % (thumb_dir, file_name)
        if not os.path.exists(thumb_dest):
            thumb = Image.open(abs_path).resize((100, 178), Image.ANTIALIAS).filter(ImageFilter.DETAIL)
            thumb.save(thumb_dest)


@app.route('/<path:subfolder>')
def gallery(subfolder):
    DOCROOT = '/var/www'
{'fraction_non_alphanumeric': 0.14106988783433994, 'fraction_numerical': 0.006902502157031924, 'mean_word_length': 2.508320726172466, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3469617', 'n_tokens_mistral': 814, 'n_tokens_neox': 783, 'n_words': 161}