<commit_before>from app import app, tempchamber
from app.auth import google, whitelist_required, admin_required
from flask import request, url_for, redirect, flash, session, jsonify

chamber = tempchamber.TempChamber()

@app.route('/')
def home():
    if 'google_token' in session:
        me = google.get('userinfo')
        return jsonify({"data": me.data})
    return 'No user data'

@app.route('/read')
@whitelist_required
def read_temp():
    try:
        temp = chamber.read_temp()
    except:
        return 'Fail! Temp read error.'
    return str(temp)

@app.route('/set')
@admin_required
def set_temp():
    try:
        temp = float(request.args.get('temp'))
    except:
        return 'Fail! Invalid argument'
    try:
        chamber.set_temp(temp)
    except:
        return 'Fail! Temp set error'
    return 'Success!'

@app.route('/login')
def login():
    return google.authorize(callback=url_for('oauth_authorized', _external=True))

@app.route('/logout')
def logout():
    session.pop('google_token', None)
    return redirect(url_for('home'))

@app.route('/oauth-authorized')
def oauth_authorized():
    resp = google.authorized_response()
    if resp is None:
        if resp is None:
            # User denied request to sign in
            return redirect(url_for('home'))
    
    session['google_token'] = (resp['access_token'], '')
    me = google.get('userinfo')
    
    return redirect(url_for('home'))<commit_msg>Update views to frontend<commit_after>from app import app, chamber
from app.auth import google, whitelist_required, admin_required
from flask import request, url_for, redirect, flash, session, jsonify, render_template

@app.route('/')
def home():
    return render_template('index.html')

@app.route('/read')
@whitelist_required
def read_temp():
    try:
        temp = chamber.read_temp()
    except:
        return 'Fail! Temp read error.'
    return str(temp)

@app.route('/set')
@admin_required
def set_temp():
    try:
        temp = float(request.args.get('temp'))
    except:
        return 'Fail! Invalid argument'
    try:
        chamber.set_temp(temp)
    except:
        return 'Fail! Temp set error'
    return 'Success!'

@app.route('/login')
def login():
    return google.authorize(callback=url_for('oauth_authorized', _external=True))

@app.route('/logout')
def logout():
    session.pop('google_token', None)
    return redirect(url_for('home'))

@app.route('/oauth-authorized')
def oauth_authorized():
    resp = google.authorized_response()
    if resp is None:
        if resp is None:
            # User denied request to sign in
            return redirect(url_for('home'))
    
    session['google_token'] = (resp['access_token'], '')
    me = google.get('userinfo')
    
    return redirect(url_for('home', token=resp['access_token']))
{'fraction_non_alphanumeric': 0.13597430406852248, 'fraction_numerical': 0.0, 'mean_word_length': 3.407232704402516, 'pattern_counts': {'":': 1, '<': 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': '3160625', 'n_tokens_mistral': 856, 'n_tokens_neox': 853, 'n_words': 221}