<commit_before>from fiole import *


@get('/test_get_data')
def index(request):
    try:
        # Should raise an error.
        return 'What? Somehow found a remote user: %s' % request.REMOTE_USER
    except KeyError:
        pass

    return render_template("""\
Remote Addr: {{ request.REMOTE_ADDR|repr|e }}<br>
GET name: {{ request.GET.get('name', 'undefined')|repr|e }}<br>
GET foo: {{ request.GET.get('foo', 'undefined')|repr|e }}
""", request=request)


@get('/simple_post')
def simple_post(request):
    with open('examples/html/simple_post.html', 'r') as f:
        return f.read()


@post('/test_post')
def test_post(request):
    return "'foo' is: %s" % request.POST.get('foo', 'not specified')


@get('/complex_post')<commit_msg>Catch AttributeError instead of KeyError in the request_environ_data example<commit_after>from fiole import *


@get('/test_get_data')
def index(request):
    try:
        # Should raise an error.
        return 'What? Somehow found a remote user: %s' % request.REMOTE_USER
    except AttributeError:
        pass

    return render_template("""\
Remote Addr: {{ request.REMOTE_ADDR|repr|e }}<br>
GET name: {{ request.GET.get('name', 'undefined')|repr|e }}<br>
GET foo: {{ request.GET.get('foo', 'undefined')|repr|e }}
""", request=request)


@get('/simple_post')
def simple_post(request):
    with open('examples/html/simple_post.html', 'r') as f:
        return f.read()


@post('/test_post')
def test_post(request):
    return "'foo' is: %s" % request.POST.get('foo', 'not specified')


@get('/complex_post')
{'fraction_non_alphanumeric': 0.17128139085640695, 'fraction_numerical': 0.0, 'mean_word_length': 4.128712871287129, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3808344', 'n_tokens_mistral': 544, 'n_tokens_neox': 522, 'n_words': 127}