<commit_before>#!/usr/bin/env python
import json
import lyric_engine
import webapp2

class MainHandler(webapp2.RequestHandler):
    def handler(self):
        url = self.request.get('url')

        if url:
            try:
                engine = lyric_engine.Lyric(url)
                lyric = engine.get_lyric()
                output = json.dumps({'lyric': lyric})
            except IOError:
                output = json.dumps({'lyric': 'IO error!'})
            except TypeError:
                output = json.dumps({'lyric': 'Type error!'})
            except IndexError:
                output = json.dumps({'lyric': 'Index error!'})
            except StandardError:
                output = json.dumps({'lyric': 'Standard Error!'})
        else:
            output = json.dumps({'lyric': 'error!'})

        self.response.headers.add('Access-Control-Allow-Origin', 'http://localhost')
        self.response.headers.add('Access-Control-Allow-Methods', 'GET,POST')
        
        self.response.write(output)
        
    def get(self):
        self.handler()

    def post(self):
        self.handler()


class NotFound(webapp2.RequestHandler):
    def get(self):
        self.redirect('http://franks543.blogspot.com/')

    def post(self):
        self.redirect('http://franks543.blogspot.com/')

app = webapp2.WSGIApplication([
    ('/app', MainHandler),
    ('/.*', NotFound)
], debug=True)<commit_msg>set allow origin to port 3000 of localhost<commit_after>#!/usr/bin/env python
import json
import lyric_engine
import webapp2

class MainHandler(webapp2.RequestHandler):
    def handler(self):
        url = self.request.get('url')

        if url:
            try:
                engine = lyric_engine.Lyric(url)
                lyric = engine.get_lyric()
                output = json.dumps({'lyric': lyric})
            except IOError:
                output = json.dumps({'lyric': 'IO error!'})
            except TypeError:
                output = json.dumps({'lyric': 'Type error!'})
            except IndexError:
                output = json.dumps({'lyric': 'Index error!'})
            except StandardError:
                output = json.dumps({'lyric': 'Standard Error!'})
        else:
            output = json.dumps({'lyric': 'error!'})

        self.response.headers.add('Access-Control-Allow-Origin', 'http://localhost:3000')
        self.response.headers.add('Access-Control-Allow-Methods', 'GET,POST')

        self.response.write(output)
        
    def get(self):
        self.handler()

    def post(self):
        self.handler()


class NotFound(webapp2.RequestHandler):
    def get(self):
        self.redirect('http://franks543.blogspot.com/')

    def post(self):
        self.redirect('http://franks543.blogspot.com/')

app = webapp2.WSGIApplication([
    ('/app', MainHandler),
    ('/.*', NotFound)
], debug=True)
{'fraction_non_alphanumeric': 0.1452064380685794, 'fraction_numerical': 0.00979706088173548, 'mean_word_length': 2.1417582417582417, 'pattern_counts': {'":': 0, '<': 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': '5273423', 'n_tokens_mistral': 883, 'n_tokens_neox': 828, 'n_words': 160}