<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Mono.Net;
using System.IO;
using System.Threading;
using Newtonsoft.Json;
using System.Web;
using Snowflake.Ajax;
using Snowflake.Extensions;
namespace Snowflake.Core.Server
{
    public class ApiServer : BaseHttpServer
    {
        public ApiServer():base(30001)
        {
            
        }

        protected override async Task Process(HttpListenerContext context)
        {
            context.AddAccessControlHeaders();
            string getRequest = context.Request.Url.AbsolutePath.Remove(0,1); //Remove first slash
            string getUri = context.Request.Url.AbsoluteUri;
            int index = getUri.IndexOf("?", StringComparison.Ordinal);
            var dictParams = new Dictionary<string, string>();
            JSRequest request;
            if (index > 0)
            {
                string rawParams = getUri.Substring(index).Remove(0, 1);
                var nvcParams = HttpUtility.ParseQueryString(rawParams);
                dictParams = nvcParams.AllKeys.ToDictionary(o => o, o => nvcParams[o]);
                request = new JSRequest(getRequest.Split('/')[0], getRequest.Split('/')[1], dictParams);
            }
            else
            {
                request = new JSRequest("", "", new Dictionary<string, string>());
            }
            
            var writer = new StreamWriter(context.Response.OutputStream);
            
            writer.WriteLine(await ProcessRequest(request));
            writer.Flush();
   <commit_msg>Fix JsonApiServer breaking if parameter operator was not present<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Mono.Net;
using System.IO;
using System.Threading;
using Newtonsoft.Json;
using System.Web;
using Snowflake.Ajax;
using Snowflake.Extensions;
namespace Snowflake.Core.Server
{
    public class ApiServer : BaseHttpServer
    {
        public ApiServer():base(30001)
        {
            
        }

        protected override async Task Process(HttpListenerContext context)
        {
            context.AddAccessControlHeaders();
            string getRequest = context.Request.Url.AbsolutePath.Remove(0,1); //Remove first slash
            string getUri = context.Request.Url.AbsoluteUri;
            int index = getUri.IndexOf("?", StringComparison.Ordinal);
            var dictParams = new Dictionary<string, string>();
            
            if (index > 0)
            {
                string rawParams = getUri.Substring(index).Remove(0, 1);
                var nvcParams = HttpUtility.ParseQueryString(rawParams);
                dictParams = nvcParams.AllKeys.ToDictionary(o => o, o => nvcParams[o]);
            }
            var request = getRequest.Split('/').Count() >= 2 ?
                new JSRequest(getRequest.Split('/')[0], getRequest.Split('/')[1], dictParams) :
                new JSRequest("","",new Dictionary<string, string>());
            
            var writer = new StreamWriter(context.Response.OutputStream);
            
            writer.WriteLine(await ProcessRequest(request));
            writer.Flush();
   
{'fraction_non_alphanumeric': 0.10581039755351682, 'fraction_numerical': 0.00764525993883792, 'mean_word_length': 2.2644710578842315, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 14, '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': '515559', 'n_tokens_mistral': 852, 'n_tokens_neox': 838, 'n_words': 192}