<commit_before>
import threading
import cgi
import wsgiref.simple_server


def app(environment, start_response):
    '''Index is mounted at '/'.'''
    start_response('200 OK', [('Content-Type', 'text/html')])
    # fp = file pinter
    post_data = cgi.FieldStorage(fp=environment['wsgi.input'],
                                 environ=environment.copy(),
                                 keep_blank_values=True)
    print(post_data)
    #return ['string']

class Server_Thread(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
        self.running = True
        self.server = wsgiref.simple_server.make_server('localhost',
                                                        8001,
                                                        app)
        print("Server_Thread initialized. Serving.")
    def run(self):
        while self.running == True:
           self.server.serve_forever()
           
if __name__ == '__main__':
    server = Server_Thread()
    server.start()
    
    
    
'''
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the 
remote resource at http://localhost:8001/. 
This can be fixed by moving the resource to the same domain or enabling CORS.
('CONTENT_TYPE', 'text/plain'), 
('SHELL', '/bin/bash'), 
('PATH_INFO', '/'), 
('REQUEST_METHOD', 'GET'), 
('USER', 'theo'), 
('REMOTE_ADDR', '127.0.0.1'), 
('SERVER_PORT', '8001'), 
('QUERY_STRING', ''), 
('LOGNAME', 'theo'), 
('HOME', '/home/theo'), 
('CONTENT_LENGTH', ''), 
('PWD', '/home/theo'),
('_', '/usr/bin/python3'),
('LANG', 'en_US.UTF-8'), <commit_msg>No wsgi needed. Just static service is fine.<commit_after>import os
import http.server
import socketserver
import threading


class SurgeoHandler(http.server.BaseHTTPRequestHandler):

    def do_GET(self):
        parent_dir = os.path.dirname(os.path.abspath(__file__))
        try:
            print(self.path)
            f = open(parent_dir + os.sep + self.path, 'rb')
            self.send_response(200)
            # Misc headers for different types
            if self.path.endswith('.png'):
                self.send_header('Content-type',
                                 'image/png')
            if self.path.endswith('.css'):
                self.send_header('Content-type',
                                 'text/css')
            if self.path.endswith('.html'):
                self.send_header('Content-type',
                                 'text/html')
                print('ha')
            if self.path.endswith('.js'):
                self.send_header('Content-type',
                                 'text/javascript')
            self.end_headers()
            self.wfile.write(f.read())
            f.close()
                
        except IOError:
            self.send_error(404)
     

    def do_POST(self):
        pass

if __name__ == '__main__':
    server = http.server.HTTPServer(('localhost', 8001),
                                    SurgeoHandler)
    server.serve_forever()
                                


    
'''
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the 
remote resource at http://localhost:8001/. 
This can be fixed by moving the resource to the same domain or enabling CORS.
('CONTENT_TYPE', 'text/plain'), 
('SHELL', '/bin/bash'), 
('PATH_INFO', '/'), 
('REQUEST_METHOD', 'GET'), 
('USER', 'theo'), 
('REMOTE_ADDR', '127.0.0.1'), 
('SERVER_PORT', '8001'), 
('QUERY_STRING', ''), 
('LOGNAME', 'theo'), 
('HOME', '/home/theo'), 
('CONTENT_LENGTH', ''), 
('PWD', '/home/theo'),
('_', '/usr/bin/python3'),
('LANG', 'en_US.UTF-8'), 
{'fraction_non_alphanumeric': 0.15173370319001386, 'fraction_numerical': 0.013592233009708738, 'mean_word_length': 2.0075062552126774, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6680288', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1063, 'n_words': 228}