<commit_before>#!/usr/bin/env python

#import os
import sys

#sys.path.append(os.path.dirname(__file__))
sys.path.append('/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages')

from urlparse import parse_qsl
import xmltree
import json


def application(environ, start_response):
    headers = [('Content-type', 'text/plain'),
               ('Access-Control-Allow-Origin', '*'), 
               ('Access-Control-Allow-Methods', 'GET'),] 
    start_response("200 OK", headers)

    xtree = xmltree.XMLTree()
    xtree.insert_query(xtree.root, 'select * from derp')
    xtree.insert_query(xtree.root, 'select * from yeah')

    ret = ''

    gets = dict(parse_qsl(environ.get('QUERY_STRING')))
    if 'userinput' in gets:
        userinput = gets['userinput']
        nodes, token = xtree.get_query_parts(userinput)
        print 'nodes', nodes
        results = xtree.find_query(' '.join(nodes))

        query = ' '.join(nodes) + ' %s'
        results = [query % result for result in results]

        print 'results', results
        ret = json.dumps(results)

    ret = ['jsonpcallback({"results": %s})' % ret,]

    return ret


if __name__ == '__main__':
    from wsgiref.simple_server import make_server
    server = make_server('localhost', 8080, application)
    server.serve_forever()<commit_msg>remove debug<commit_after>#!/usr/bin/env python

#import os
import sys

#sys.path.append(os.path.dirname(__file__))
sys.path.append('/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages')

from urlparse import parse_qsl
import xmltree
import json


def application(environ, start_response):
    headers = [('Content-type', 'text/plain'),
               ('Access-Control-Allow-Origin', '*'), 
               ('Access-Control-Allow-Methods', 'GET'),] 
    start_response("200 OK", headers)

    xtree = xmltree.XMLTree()
    xtree.insert_query(xtree.root, 'select * from derp')
    xtree.insert_query(xtree.root, 'select * from yeah')

    ret = ''

    gets = dict(parse_qsl(environ.get('QUERY_STRING')))
    if 'userinput' in gets:
        userinput = gets['userinput']
        nodes, token = xtree.get_query_parts(userinput)
        results = xtree.find_query(' '.join(nodes))

        query = ' '.join(nodes) + ' %s'
        results = [query % result for result in results]

        ret = json.dumps(results)

    ret = ['jsonpcallback({"results": %s})' % ret,]

    return ret


if __name__ == '__main__':
    from wsgiref.simple_server import make_server
    server = make_server('localhost', 8080, application)
    server.serve_forever()
{'fraction_non_alphanumeric': 0.14520443255636226, 'fraction_numerical': 0.008406572411157814, 'mean_word_length': 3.2777777777777777, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '1497714', 'n_tokens_mistral': 874, 'n_tokens_neox': 839, 'n_words': 172}