<commit_before>import json
from pymongo import *
from bson.code import *
def application(environ, start_response):
    #set the headers
    status = '200 OK'
    response_headers = [('Content-type', 'text/plain'),('Access-Control-Allow-Origin', '*')]
    start_response(status, response_headers)
    
    try:
        #read the request
        recieved = environ['wsgi.input'].read(int(environ['CONTENT_LENGTH']))
        #print >> environ['wsgi.errors'], recieved
    except KeyError:
        #print >> environ['wsgi.errors'], recieved
        return 'empty'
    
    else:
        #connect to the DB
        connection = Connection('localhost',27017)
        db = connection['alipi']
        collection = db['post']
        #get the ren languages for the received url
        langForUrl = collection.group(
            key = Code('function(doc){return {"url" : doc.url}}'),
            condition={"url" : recieved},
            initial={'lang': []},
            reduce=Code('function(doc, out){if (out.lang.indexOf(doc.lang) == -1) out.lang.push(doc.lang)}') #here xpath for test
            )
        
        #send the response
        if (langForUrl):
            return json.dumps(langForUrl[0]['lang'])
        else:
            return "empty"
       
        <commit_msg>Menu creation<commit_after>import json
from pymongo import *
from bson.code import *
from urllib import unquote_plus 
def application(environ, start_response):
    #set the headers
    status = '200 OK'
    response_headers = [('Content-type', 'text/plain'),('Access-Control-Allow-Origin', '*')]
    start_response(status, response_headers)
    
    try:
        #read the request
        recieved = environ['wsgi.input'].read(int(environ['CONTENT_LENGTH']))
        d={}
        parameter_pairs = recieved.split('&') 
        for parameter_pair in parameter_pairs:        
            parameter_pair = parameter_pair.split('=',1) 
            d[unquote_plus(parameter_pair[0])]  = unquote_plus(parameter_pair[1])

    except KeyError:
        #print >> environ['wsgi.errors'], recieved
        return 'empty'
    
    else:
        #connect to the DB
        if d.has_key('option') == False:
            connection = Connection('localhost',27017)
            db = connection['alipi']
            collection = db['post']
        #get the ren languages for the received url
            langForUrl = collection.group(
                key = Code('function(doc){return {"url" : doc.url}}'),
                condition={"url" : d['url']},
                initial={'lang': []},
                reduce=Code('function(doc, out){if (out.lang.indexOf(doc.lang) == -1) out.lang.push(doc.lang)}') #here xpath for test
            )
        
        #send the response
            if (langForUrl):
                return json.dumps(langForUrl[0]['lang'])
            else:
                return "empty"
        else:
            connection = Connection('localhost',27017)
            db = connection['alipi']
            collection = db['post']
        #get the ren languages for the received url
            langForUrl = collection.group(
                key = Code('function(doc){return {"url" : doc.url}}'),
                condition={"url" : d['url'],"blog":{'$regex':'/'+d['option']+'.*/'}},
                initial={'lang': []},
                reduce=Code('function(doc, out){if (out.lang.indexOf(doc.lang) == -1) out.lang.push(doc.lang)}') #here xpath for test
            )
        
        #send the response
            if (langForUrl):
                return json.dumps(langForUrl[0]['lang'])
            else:
                return "empty"

{'fraction_non_alphanumeric': 0.14060773480662983, 'fraction_numerical': 0.008287292817679558, 'mean_word_length': 2.126943005181347, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 9, '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': '6386831', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1030, 'n_words': 229}