<commit_before>"""Serves static files with optional directory index.

Files in static folder are automatically served on static URL by Flask.
See http://flask.pocoo.org/docs/0.10/api/#application-object.

It's recommended to specify static folder and URL path directly on Flask application object,
unless you need additional static folders, or have multiple route handlers for the URL path,
e.g. when serving static files on root URL ('') for any path unmatched with previous routes.
"""

__all__ = 'add'.split()
__version__ = '0.1.1'

import os
from flask import send_from_directory

def add(app, url = None, path = None, endpoint=None, index='index.html'):
    """Adds static files endpoint with optional directory index."""
    url = url or app.static_url_path or ''
    path = os.path.abspath(path or app.static_folder or '.')
    endpoint = endpoint or 'static_' + os.path.basename(path)

    if path == app.static_folder:
        if url != app.static_url_path:
            raise ValueError('Files in `{}` path are automatically served on `{}` URL by Flask.'
                ' Use different path for serving them at `{}` URL'.format(path, app.static_url_path, url))
    else:
         @app.route(url + '/<path:filename>', endpoint = endpoint)
         def static_files(filename):
             return send_from_directory(path, filename)

    if index:
         @app.route(url + '/', endpoint = endpoint + '_index')
         def static_index():
             return send_from_directory(path, index)

         if url:
             @app.route(url, endpoint = endpoint + '_index_bare')
             def static_index_bare():
                 return send_from_directory(path, index)
<commit_msg>chore: fix setup without flask installed<commit_after>"""Serves static files with optional directory index.

Files in static folder are automatically served on static URL by Flask.
See http://flask.pocoo.org/docs/0.10/api/#application-object.

It's recommended to specify static folder and URL path directly on Flask application object,
unless you need additional static folders, or have multiple route handlers for the URL path,
e.g. when serving static files on root URL ('') for any path unmatched with previous routes.
"""

__all__ = 'add'.split()
__version__ = '0.1.1'

import os

def add(app, url = None, path = None, endpoint=None, index='index.html', send_from_directory=None):
    """Adds static files endpoint with optional directory index."""

    if not send_from_directory:
        from flask import send_from_directory

    url = url or app.static_url_path or ''
    path = os.path.abspath(path or app.static_folder or '.')
    endpoint = endpoint or 'static_' + os.path.basename(path)

    if path == app.static_folder:
        if url != app.static_url_path:
            raise ValueError('Files in `{}` path are automatically served on `{}` URL by Flask.'
                ' Use different path for serving them at `{}` URL'.format(path, app.static_url_path, url))
    else:
         @app.route(url + '/<path:filename>', endpoint = endpoint)
         def static_files(filename):
             return send_from_directory(path, filename)

    if index:
         @app.route(url + '/', endpoint = endpoint + '_index')
         def static_index():
             return send_from_directory(path, index)

         if url:
             @app.route(url, endpoint = endpoint + '_index_bare')
             def static_index_bare():
                 return send_from_directory(path, index)

{'fraction_non_alphanumeric': 0.1029031330842196, 'fraction_numerical': 0.0034492670307559644, 'mean_word_length': 3.0749414519906324, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1952842', 'n_tokens_mistral': 978, 'n_tokens_neox': 956, 'n_words': 339}