<commit_before>#!/bin/env python

from flask import Flask, jsonify, make_response
from hn import HN

app = Flask(__name__)

@app.route('/')
def index():
    return "<b>Check out <a href=\"https://github.com/thekarangoel/HNify\">HNify on Github</a>.</b>"

@app.route('/get/top', methods = ['GET'])
def get_top():
    hn = HN()
    return jsonify({'stories': hn.get_stories()})

@app.route('/get/<story_type>', methods = ['GET'])
def get_stories(story_type):
    hn = HN()
    return jsonify({'stories': hn.get_stories(story_type=story_type)})

@app.errorhandler(404)
def not_found(error):
    return make_response(jsonify( { 'error': 'Not found' } ), 404)<commit_msg>Better docs<commit_after>#!/bin/env python

from flask import Flask, jsonify, make_response
from hn import HN

app = Flask(__name__)

@app.route('/')
def index():
    '''
    This page is displayed when index page is requested.
    '''
    return '''<b>Check out <a href="https://github.com/thekarangoel/HNify">HNify on Github</a>.</b>'''

@app.route('/get/top', methods = ['GET'])
def get_top():
    '''
    Returns stories from the front page of HN.
    '''
    hn = HN()
    return jsonify({'stories': hn.get_stories()})

@app.route('/get/<story_type>', methods = ['GET'])
def get_stories(story_type):
    '''
    Returns stories from the requested page of HN.
    story_type is one of:
    \tnewest
    \tbest
    '''
    hn = HN()
    return jsonify({'stories': hn.get_stories(story_type=story_type)})

@app.errorhandler(404)
def not_found(error):
    '''
    Returns a jsonified 404 error message instead of a HTTP 404 error.
    '''
    return make_response(jsonify( { 'error': 'Not found' } ), 404)
{'fraction_non_alphanumeric': 0.1728468899521531, 'fraction_numerical': 0.01076555023923445, 'mean_word_length': 3.877551020408163, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, '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': '4051376', 'n_tokens_mistral': 620, 'n_tokens_neox': 581, 'n_words': 149}