<commit_before># feedparser doc
# http://pythonhosted.org/feedparser/basic.html

import os
import json
import webapp2
import json
import urllib

import feedparser
import utils

from google.appengine.ext.webapp import util
from model import Tag

class TagsHandler(webapp2.RequestHandler):
    def get(self):
        """Gets the tags for the logged in user"""
        user = utils.get_current_user_model()
        
        if not user:
            self.error(403)
            return
            
        tags = Tag.all().ancestor(user.key())
            
        self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
        self.response.headers['Access-Control-Allow-Origin'] = '*'
        
        tags = [i.to_struct() for i in tags]
        
        self.response.out.write(json.dumps(tags))
        
    def post(self):
        """Creates a new tag for the logged in user"""
        user = utils.get_current_user_model()
        title = self.request.get('title')
        
        if not user:
            self.error(403)
            return
        
        if not title:
            self.error(400)

        m = Tag(
            parent=user.key(),
            title=title,
            title_lower=title.lower(),
        )
        m.put()
        
        self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
        self.response.headers['Access-Control-Allow-Origin'] = '*'
        self.response.out.write('ok')

app = webapp2.WSGIApplication([
    ('/tags', TagsHandler),
], debug=True)
<commit_msg>Fixed return type for /tags<commit_after># feedparser doc
# http://pythonhosted.org/feedparser/basic.html

import os
import json
import webapp2
import json
import urllib

import feedparser
import utils

from google.appengine.ext.webapp import util
from model import Tag

class TagsHandler(webapp2.RequestHandler):
    def get(self):
        """Gets the tags for the logged in user"""
        user = utils.get_current_user_model()
        
        if not user:
            self.error(403)
            return
            
        tags = Tag.all().ancestor(user.key())
            
        self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
        self.response.headers['Access-Control-Allow-Origin'] = '*'
        
        tags = [i.to_struct() for i in tags]
        
        self.response.out.write(json.dumps(tags))
        
    def post(self):
        """Creates a new tag for the logged in user"""
        user = utils.get_current_user_model()
        title = self.request.get('title')
        
        if not user:
            self.error(403)
            return
        
        if not title:
            self.error(400)

        m = Tag(
            parent=user.key(),
            title=title,
            title_lower=title.lower(),
        )
        m.put()
        
        self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'
        self.response.headers['Access-Control-Allow-Origin'] = '*'
        self.response.out.write('ok')

app = webapp2.WSGIApplication([
    ('/tags', TagsHandler),
], debug=True)

{'fraction_non_alphanumeric': 0.11774193548387096, 'fraction_numerical': 0.00903225806451613, 'mean_word_length': 1.9533333333333334, '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': '7328696', 'n_tokens_mistral': 930, 'n_tokens_neox': 911, 'n_words': 200}