# Path: auth/kancolle.py
# class KancolleAuth:
#     def __init__(self, login_id, password):
#     def __del__(self):
#     def _request(self, url, method='GET', data=None, timeout_message='连接失败', timeout=10):
#     def _get_dmm_tokens(self):
#     def _get_ajax_token(self):
#     def _get_osapi_url(self):
#     def _get_world(self):
#     def _get_api_token(self):
#     def get_osapi(self):
#     def get_entry(self):


import asyncio
import aiohttp.web
import aiohttp_jinja2
from aiohttp_session import get_session
from auth.kancolle import KancolleAuth, OOIAuthException

        :param request: aiohttp.web.Request
        :return: dict
        """
        session = yield from get_session(request)
        if 'mode' in session:
            mode = session['mode']
        else:
            session['mode'] = 1
            mode = 1

        return {'mode': mode}

    @asyncio.coroutine
    def login(self, request):
        """接受登录表单提交的数据，登录后跳转或登录失败后展示错误信息。

        :param request: aiohttp.web.Request
        :return: aiohttp.web.HTTPFound or aiohttp.web.Response
        """
        post = yield from request.post()
        session = yield from get_session(request)

        login_id = post.get('login_id', None)
        password = post.get('password', None)
        mode = int(post.get('mode', 1))

        session['mode'] = mode

        if login_id and password:

# Path: auth/kancolle.py
# class KancolleAuth:
#     def __init__(self, login_id, password):
#     def __del__(self):
#     def _request(self, url, method='GET', data=None, timeout_message='连接失败', timeout=10):
#     def _get_dmm_tokens(self):
#     def _get_ajax_token(self):
#     def _get_osapi_url(self):
#     def _get_world(self):
#     def _get_api_token(self):
#     def get_osapi(self):
#     def get_entry(self):


# Path: handlers/frontend.py
import asyncio
import aiohttp.web
import aiohttp_jinja2
from aiohttp_session import get_session
from auth.kancolle import KancolleAuth, OOIAuthException


        :param request: aiohttp.web.Request
        :return: dict
        """
        session = yield from get_session(request)
        if 'mode' in session:
            mode = session['mode']
        else:
            session['mode'] = 1
            mode = 1

        return {'mode': mode}

    @asyncio.coroutine
    def login(self, request):
        """接受登录表单提交的数据，登录后跳转或登录失败后展示错误信息。

        :param request: aiohttp.web.Request
        :return: aiohttp.web.HTTPFound or aiohttp.web.Response
        """
        post = yield from request.post()
        session = yield from get_session(request)

        login_id = post.get('login_id', None)
        password = post.get('password', None)
        mode = int(post.get('mode', 1))

        session['mode'] = mode

        if login_id and password:

            kancolle = KancolleAuth(login_id, password)