<commit_before>import functools
import hashlib, hmac
import json
from flask import (Flask, request, render_template, redirect,
                   url_for, session, abort)
from .model import db, Topic
import requests

app = Flask(__name__)
app.config.from_pyfile('../default.cfg')
db.init_app(app)


def login_required(f):
    @functools.wraps(f)
    def wrapped(*args, **kwargs):
        if 'username' not in session:
            return redirect(url_for('login_form'))
        else:
            return f(*args, **kwargs)
    return wrapped


def valid_login(username, password):
    url = 'http://langdev.org/apps/{0}/sso/{1}?error=ignore' \
        .format(app.config['LANGDEV_APP_KEY'], username)
    hashed_password = <PASSWORD>(<PASSWORD>()
    payload = hmac.new(app.config['LANGDEV_SECRET_KEY'], hashed_password,
                       digestmod=hashlib.sha1).hexdigest()
    result = requests.post(url, data={'password': payload},
                                headers={'Accept': 'application/json'})
    if result.status_code == requests.codes.ok:
        return json.loads(result.content)
    else:
        return False


@app.route('/')
def root():
    topics = Topic.query.all()
    return render_template('index.html', topics=topics)


@app.route('/topic/<int:topic_id>')
def topic(topic_id):
    topic = Topic.query.get_or_404(topic_id)
    return render_template('topic.html', topic=topic)


@app.route('/topic/new')
@login_required
def write_topic():
    return render_template('write.html')

<commit_msg>SSO API domain has changed.<commit_after>import functools
import hashlib, hmac
import json
from flask import (Flask, request, render_template, redirect,
                   url_for, session, abort)
from .model import db, Topic
import requests

app = Flask(__name__)
app.config.from_pyfile('../default.cfg')
db.init_app(app)


def login_required(f):
    @functools.wraps(f)
    def wrapped(*args, **kwargs):
        if 'username' not in session:
            return redirect(url_for('login_form'))
        else:
            return f(*args, **kwargs)
    return wrapped


def valid_login(username, password):
    url = 'http://langdev.org/apps/{0}/sso/{1}?error=ignore' \
        .format(app.config['LANGDEV_APP_KEY'], username)
    hashed_password = hashlib.md5(password).hexdigest()
    payload = hmac.new(app.config['LANGDEV_SECRET_KEY'], hashed_password,
                       digestmod=hashlib.sha1).hexdigest()
    result = requests.post(url, data={'password': payload},
                                headers={'Accept': 'application/json'},
                                allow_redirects=True)
    if result.status_code == requests.codes.ok:
        return json.loads(result.content)
    else:
        return False


@app.route('/')
def root():
    topics = Topic.query.all()
    return render_template('index.html', topics=topics)


@app.route('/topic/<int:topic_id>')
def topic(topic_id):
    topic = Topic.query.get_or_404(topic_id)
    return render_template('topic.html', topic=topic)


@app.route('/topic/new')
@login_required
def write_topic():
    return render_template('write.html')


{'fraction_non_alphanumeric': 0.1364509929532351, 'fraction_numerical': 0.004163997437540038, 'mean_word_length': 3.147410358565737, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7609214', 'n_tokens_mistral': 990, 'n_tokens_neox': 970, 'n_words': 197}