<commit_before>#r "Newtonsoft.Json"

using System.Net;
using System.Net.Http;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

public static HttpResponseMessage Run(HttpRequestMessage req, string tableName, int? id, TraceWriter log)
{
    var sql = "";
    var method = req.Method.ToString();

    switch (method) {
        case "GET":
            log.Info("SELECT");
            sql = Processor.Get(tableName, id);
            break;
        case "POST":
            log.Info("INSERT");
            sql = Processor.Add(tableName, req.Content);
            break;
        // case "PUT":
        // case "PATCH":
        //     log.Info("UPDATE");
        //     break;
        // case "DELETE":
        //     log.Info("PSOT");
        //     break;
        default:
            return req.CreateResponse(HttpStatusCode.NotImplemented);
    }

    var connString = ConfigurationManager.ConnectionStrings["db"].ConnectionString;
    if (method == "GET")
    {
        var dt = Processor.ExecuteSqlSelect(connString, sql);
        if (dt != null) {
            var json = "";
            var serializerSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() };
            json = JsonConvert.SerializeObject(dt, serializerSettings);
            return req.CreateResponse(HttpStatusCode.OK, json);
        } else {<commit_msg>Create new HttpResponseMessage with application/json header<commit_after>#r "Newtonsoft.Json"

using System.Net;
using System.Net.Http;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

public static HttpResponseMessage Run(HttpRequestMessage req, string tableName, int? id, TraceWriter log)
{
    var sql = "";
    var method = req.Method.ToString();

    switch (method) {
        case "GET":
            log.Info("SELECT");
            sql = Processor.Get(tableName, id);
            break;
        case "POST":
            log.Info("INSERT");
            sql = Processor.Add(tableName, req.Content);
            break;
        // case "PUT":
        // case "PATCH":
        //     log.Info("UPDATE");
        //     break;
        // case "DELETE":
        //     log.Info("PSOT");
        //     break;
        default:
            return req.CreateResponse(HttpStatusCode.NotImplemented);
    }

    var connString = ConfigurationManager.ConnectionStrings["db"].ConnectionString;
    if (method == "GET")
    {
        var dt = Processor.ExecuteSqlSelect(connString, sql);
        if (dt != null) {
            var json = "";
            var serializerSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() };
            json = JsonConvert.SerializeObject(dt, serializerSettings);
            return new HttpResponseMessage(HttpStatusCode.OK){ 
                Content = new StringContent(json, Encoding.UTF8, "application/json") 
                };
        } else {
{'fraction_non_alphanumeric': 0.11462574381459442, 'fraction_numerical': 0.00031318509238960227, 'mean_word_length': 2.344502617801047, 'pattern_counts': {'":': 10, '<': 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': '2827242', 'n_tokens_mistral': 846, 'n_tokens_neox': 845, 'n_words': 198}