<commit_before>﻿using Microsoft.Owin.Hosting;
using Owin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Microsoft.Owin;

namespace OwinSelfHosted
{
    using AppFunc = Func<IDictionary<string, object>, Task>;

    class Program
    {
        static void Main(string[] args)
        {
            string url = "http://localhost:12345";
            Console.WriteLine("Starting web application...");
            using (WebApp.Start(url, Startup))
            {
                Console.WriteLine("Application listening on {0}.", url);
                Console.WriteLine("Press any key to quit.");

                Console.ReadKey();
                Console.WriteLine();
            }

            Console.WriteLine("Application shut down.");
        }

        static void Startup(IAppBuilder app)
        {
            app.Use(new Func<AppFunc, AppFunc>(LoggingMiddleware));

            app.Use(typeof(StartPageMiddleware));

            app.Use(async (context, next) =>
            {
                if (context.Request.Path == new PathString("/Fail"))
                {
                    throw new InvalidOperationException();
                }
                await next.Invoke();
            });
        }

        static AppFunc LoggingMiddleware(AppFunc next)
        {
            return async environment =>
                {
                    Console.WriteLine("Receiving request for \"{0}\"", environment["owin.RequestPath"]);

                    await next.Invoke(environment);

                    Console.WriteLine("Returning with status {0}", environment["owin.ResponseStatusCode"]);
                };
        }
    }
}
<commit_msg>Added error page handler.<commit_after>﻿using Microsoft.Owin.Hosting;
using Owin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Microsoft.Owin;

namespace OwinSelfHosted
{
    using AppFunc = Func<IDictionary<string, object>, Task>;

    class Program
    {
        static void Main(string[] args)
        {
            string url = "http://localhost:12345";
            Console.WriteLine("Starting web application...");
            using (WebApp.Start(url, Startup))
            {
                Console.WriteLine("Application listening on {0}.", url);
                Console.WriteLine("Press any key to quit.");

                Console.ReadKey();
                Console.WriteLine();
            }

            Console.WriteLine("Application shut down.");
        }

        static void Startup(IAppBuilder app)
        {
            app.UseErrorPage();

            app.Use(new Func<AppFunc, AppFunc>(LoggingMiddleware));

            app.Use(typeof(StartPageMiddleware));

            app.Use(async (context, next) =>
            {
                if (context.Request.Path == new PathString("/Fail"))
                {
                    throw new InvalidOperationException();
                }
                await next.Invoke();
            });
        }

        static AppFunc LoggingMiddleware(AppFunc next)
        {
            return async environment =>
                {
                    Console.WriteLine("Receiving request for \"{0}\"", environment["owin.RequestPath"]);

                    await next.Invoke(environment);

                    Console.WriteLine("Returning with status {0}", environment["owin.ResponseStatusCode"]);
                };
        }
    }
}

{'fraction_non_alphanumeric': 0.11079625956361576, 'fraction_numerical': 0.004533862283933126, 'mean_word_length': 1.7237654320987654, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '2194599', 'n_tokens_mistral': 893, 'n_tokens_neox': 849, 'n_words': 192}