<commit_before>import os
import re
import errno
import requests
from flask import Flask, safe_join, abort, url_for
from .renderer import render_page


default_filenames = ['README.md', 'README.markdown']


def serve(path=None, host=None, port=None, gfm=False, context=None,
          render_offline=False):
    """Starts a server to render the specified file or directory containing a README."""
    if not path or os.path.isdir(path):
        path = _find_file(path)

    if not os.path.exists(path):
        raise ValueError('File not found: ' + path)

    directory = os.path.dirname(path)

    # Flask application
    app = Flask('grip')
    app.config.from_pyfile('default_config.py')
    app.config.from_pyfile('local_config.py', silent=True)

    # Get styles from style source
    @app.before_first_request
    def retrieve_styles():
        if not (app.config['STYLE_URL_SOURCE'] and app.config['STYLE_URL_RE'] and app.config['STYLE_CACHE']):
            return

        styles = _get_styles(app.config['STYLE_URL_SOURCE'], app.config['STYLE_URL_RE'],
                             app.config['STYLE_CACHE'])
        app.config['STYLE_URLS'] += styles
        if app.config['DEBUG_GRIP']:
            print ' * Retrieved %s style URL%s' % (len(styles), '' if len(styles) == 1 else 's')<commit_msg>Use implicit name variable for Flask.<commit_after>import os
import re
import errno
import requests
from flask import Flask, safe_join, abort, url_for
from .renderer import render_page


default_filenames = ['README.md', 'README.markdown']


def serve(path=None, host=None, port=None, gfm=False, context=None,
          render_offline=False):
    """Starts a server to render the specified file or directory containing a README."""
    if not path or os.path.isdir(path):
        path = _find_file(path)

    if not os.path.exists(path):
        raise ValueError('File not found: ' + path)

    directory = os.path.dirname(path)

    # Flask application
    app = Flask(__name__)
    app.config.from_pyfile('default_config.py')
    app.config.from_pyfile('local_config.py', silent=True)

    # Get styles from style source
    @app.before_first_request
    def retrieve_styles():
        if not (app.config['STYLE_URL_SOURCE'] and app.config['STYLE_URL_RE'] and app.config['STYLE_CACHE']):
            return

        styles = _get_styles(app.config['STYLE_URL_SOURCE'], app.config['STYLE_URL_RE'],
                             app.config['STYLE_CACHE'])
        app.config['STYLE_URLS'] += styles
        if app.config['DEBUG_GRIP']:
            print ' * Retrieved %s style URL%s' % (len(styles), '' if len(styles) == 1 else 's')
{'fraction_non_alphanumeric': 0.12101669195751139, 'fraction_numerical': 0.0007587253414264037, 'mean_word_length': 3.2878048780487803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5236240', 'n_tokens_mistral': 850, 'n_tokens_neox': 815, 'n_words': 206}