<commit_before>#!/usr/bin/env python
"""
serv.py (the actual webapp)
part of PlainReader by <NAME>
created: 2011-11-05
released under the MIT license (see LICENSE.txt for details)
"""

from bottle import *
import newsblur_interface
import instapaper

nb = newsblur_interface.Interface()

@route('/refresh')
def refresh():
    nb.refresh();

@route('/unread')
def unread():
    return nb.stories()

@get('/all_read')
def mark_all_as_read():
    nb.markAllAsRead()
    
@get('/text')
def instapaper_text():
    url = request.GET['url']
    if url:
        ip = instapaper.instapaper(url)
        story = ip.story()
        return """%s""" % story
    else:
        return '<h1>URL not supplied</h1>'

@get('/login')
def login_form():
    return template('login')
@post('/login')
def login_submit():
    username = request.forms.get('username')
    password = request.forms.get('password')
    nb.login(username, password)
    redirect('/')
        
# route static files
@route('/:path#.+#')
def server_static(path):
    response.headers['Cache-Control'] = 'no-cache'
    return static_file(path, root='static/')

# index
@route('/')
def index():
    if nb.checkAuth():
        return static_file('index.html', root='static/')
    else:
        redirect('/login')

debug(True)
run(host='0.0.0.0', port=8181, reloader=True)<commit_msg>launch default browser and load PlainReader URL on server start<commit_after>#!/usr/bin/env python
"""
serv.py (the actual webapp)
part of PlainReader by <NAME>
created: 2011-11-05
released under the MIT license (see LICENSE.txt for details)
"""

from bottle import *
import newsblur_interface
import instapaper
import webbrowser
from threading import Timer

nb = newsblur_interface.Interface()

def openBrowser():
    webbrowser.open('http://localhost:8181')

@route('/refresh')
def refresh():
    nb.refresh();

@route('/unread')
def unread():
    return nb.stories()

@get('/all_read')
def mark_all_as_read():
    nb.markAllAsRead()
    
@get('/text')
def instapaper_text():
    url = request.GET['url']
    if url:
        ip = instapaper.instapaper(url)
        story = ip.story()
        return """%s""" % story
    else:
        return '<h1>URL not supplied</h1>'

@get('/login')
def login_form():
    return template('login')
@post('/login')
def login_submit():
    username = request.forms.get('username')
    password = <PASSWORD>('password')
    nb.login(username, password)
    redirect('/')
        
# route static files
@route('/:path#.+#')
def server_static(path):
    response.headers['Cache-Control'] = 'no-cache'
    return static_file(path, root='static/')

# index
@route('/')
def index():
    if nb.checkAuth():
        return static_file('index.html', root='static/')
    else:
        redirect('/login')

# open browser in 2 seconds
Timer(2, openBrowser, ()).start()

debug(True)
run(host='0.0.0.0', port=8181, reloader=True)
{'fraction_non_alphanumeric': 0.16602987148315387, 'fraction_numerical': 0.014588398749565822, 'mean_word_length': 3.721311475409836, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1097764', 'n_tokens_mistral': 980, 'n_tokens_neox': 937, 'n_words': 233}