<commit_before># -*- coding: utf-8 -*-

import os
import json
from functools import wraps

import requests
import uniout
import kuas.ap
import kuas.user
import kuas.parse as parse
import kuas.function as function

from flask import Flask, render_template, request, session
from flask_cors import *

__version__ = "2.0"

android_version = "1.5.4"
android_donate_version = "2.0.0"
ios_version = "1.4.3"

app = Flask(__name__)
app.config.from_object("config")


def authenticate(func):
    @wraps(func)
    def call(*args, **kwargs):
        if 'c' in session:
            return func(*args, **kwargs)
        else:
            return "false"

    return call


def dump_cookies(cookies_list):
    """Dumps cookies to list
    """

    cookies = []
    for c in cookies_list:
        cookies.append({
            'name': c.name,
            'domain': c.domain,
            'value': c.value
            })

    return cookies


def set_cookies(s, cookies):
    for c in cookies:
        s.cookies.set(c['name'], c['value'], domain=c['domain'])


@app.route('/')
def index():
    return "Hello, World!"


@app.route('/version')
@cross_origin(supports_credentials=True)
def version():
    return android_version


@app.route('/android_version')
@cross_origin(supports_credentials=True)
def a_version():
    return android_version


@app.route('/android_donate_version')
@cross_origin(supports_credentials=True)
def a_donate_version():
    return android_donate_version


@app.route('/ios_version')
@cross_origin(supports_credentials=True)
def i_version():
    return ios_version


@app.route('/fixed')
@cross_origin(supports_credentials=True)
def is_fixed():
    return ""


@app.route('/backup')
@cross_origin(supports_credentials=True)
def backup():
    return "0"


@app.route('/status')
@cross_origin(supports_credentials=True)
def status():
    return json.dumps(function.server_status())


# First v2
@app.route('/v2/ap/semester')
@cross_origin(supports_credentials=True)
def ap_semester():
    return json.dumps({"semester": kuas.ap.get_semester_list()}, ensure_ascii=False)


@app.route('/ap/login', methods=['POST'])
@cross_origin(supports_credentials=True)
def login_post():
    if request.method == "POST":
        session.permanent=True

        # Start login
        username=request.form['username']
        password=request.form['password']

        s=requests.session()<commit_msg>Fixed /v2/ap/semester with default in json<commit_after># -*- coding: utf-8 -*-

import os
import json
from functools import wraps

import requests
import uniout
import kuas.ap
import kuas.user
import kuas.parse as parse
import kuas.function as function

from flask import Flask, render_template, request, session
from flask_cors import *

__version__ = "2.0"

android_version = "1.5.4"
android_donate_version = "2.0.0"
ios_version = "1.4.3"

app = Flask(__name__)
app.config.from_object("config")


def authenticate(func):
    @wraps(func)
    def call(*args, **kwargs):
        if 'c' in session:
            return func(*args, **kwargs)
        else:
            return "false"

    return call


def dump_cookies(cookies_list):
    """Dumps cookies to list
    """

    cookies = []
    for c in cookies_list:
        cookies.append({
            'name': c.name,
            'domain': c.domain,
            'value': c.value
            })

    return cookies


def set_cookies(s, cookies):
    for c in cookies:
        s.cookies.set(c['name'], c['value'], domain=c['domain'])


@app.route('/')
def index():
    return "Hello, World!"


@app.route('/version')
@cross_origin(supports_credentials=True)
def version():
    return android_version


@app.route('/android_version')
@cross_origin(supports_credentials=True)
def a_version():
    return android_version


@app.route('/android_donate_version')
@cross_origin(supports_credentials=True)
def a_donate_version():
    return android_donate_version


@app.route('/ios_version')
@cross_origin(supports_credentials=True)
def i_version():
    return ios_version


@app.route('/fixed')
@cross_origin(supports_credentials=True)
def is_fixed():
    return ""


@app.route('/backup')
@cross_origin(supports_credentials=True)
def backup():
    return "0"


@app.route('/status')
@cross_origin(supports_credentials=True)
def status():
    return json.dumps(function.server_status())


# First v2
@app.route('/v2/ap/semester')
@cross_origin(supports_credentials=True)
def ap_semester():
    semester_list = kuas.ap.get_semester_list()
    default_yms = list(filter(lambda x: x['selected'], semester_list))[0]
    return json.dumps({"semester": semester_list,
                       "default_yms": default_yms}, ensure_ascii=False)


@app.route('/ap/login', methods=['POST'])
@cross_origin(supports_credentials=True)
def login_post():
    if request.method == "POST":
        session.permanent=True

        # Start login
        username=request.form['username']
        password=request.form['password']

        s=requests.session()
{'fraction_non_alphanumeric': 0.13621730382293762, 'fraction_numerical': 0.006438631790744467, 'mean_word_length': 3.766059443911793, 'pattern_counts': {'":': 5, '<': 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': '6465716', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1626, 'n_words': 347}