@app.route('/member/signup', methods=['POST', 'GET'])
async def wiki_signup(request):
    async with aiofiles.open('data/setting.json', encoding='utf8') as f:
        setting_data = json.loads((await f.read()))
        db = (await aiosqlite.connect((setting_data['db_name'] + '.db')))
    if (request.ctx.session.get('id') == 1):
        return response.redirect('/')
    if (request.method == 'POST'):
        signup_id = request.form.get('wiki_signup_textbox_1', '')
        signup_password_1 = request.form.get('wiki_signup_textbox_2', '')
        signup_password_2 = request.form.get('wiki_signup_textbox_3', '')
        if ((not signup_password_1) and (not signup_password_2)):
            return response.redirect('/error/')
        if (signup_password_1 != signup_password_2):
            return response.redirect('/error/')
        if re.search('(?:[^A-Za-z0-9가-힣])', signup_id):
            return response.redirect('/error/')
        if ((len(signup_id) > 24) or (len(signup_id) < 3)):
            return response.redirect('/error/')
        id_check = (await db.execute('select id from mbr where id = ?', [signup_id]))
        id_check = (await id_check.fetchall())
        if id_check:
            return response.redirect('/error/')
        encode_password = (await password_encode(signup_password_1, signup_id))
        first_check = (await db.execute('select * from mbr limit 1'))
        first_check = (await first_check.fetchall())
        if (not first_check):
            (await db.execute('insert into mbr (id, pw, acl, date, email) values (?, ?, ?, ?, ?)', [signup_id, encode_password, 'owner', (await date_time()), '']))
            (await db.execute('insert into mbr_log (name, ip, ua, today) values (?, ?, ?, ?)', [signup_id, '0', '0', (await date_time())]))
            (await db.commit())
            return response.redirect('/member/login')
        else:
            (await db.execute('insert into mbr (id, pw, acl, date, email) values (?, ?, ?, ?, ?)', [signup_id, encode_password, 'member', (await date_time()), '']))
            (await db.execute('insert into mbr_log (name, ip, ua, today) values (?, ?, ?, ?)', [signup_id, '0', '0', (await date_time())]))
            (await db.commit())
            return response.redirect('/member/login')
    return jinja.render('index.html', request, wiki_set=(await wiki_set(request, 0)), data='\n            <form method="post">\n                <input type="text" placeholder="아이디" class="wiki_textbox" name="wiki_signup_textbox_1">\n                <hr class="wiki_hr">\n                <input type="password" placeholder="비밀번호" class="wiki_textbox" name="wiki_signup_textbox_2">\n                <hr class="wiki_hr">\n                <input type="password" placeholder="비밀번호 확인" class="wiki_textbox" name="wiki_signup_textbox_3">\n                <hr class="wiki_hr">\n                <button type="submit" class="wiki_button" name="wiki_signup_button_1">확인</button>\n            </form>\n        ', title='계정 만들기', sub=0, menu=0)
@app.route('/member/signup', methods=['POST', 'GET'])
async def wiki_signup(request):
    async with aiofiles.open('data/setting.json', encoding='utf8') as f:
        setting_data = json.loads((await f.read()))
        db = (await aiosqlite.connect((setting_data['db_name'] + '.db')))
    if (request.ctx.session.get('id') == 1):
        return response.redirect('/')
    if (request.method == 'POST'):
        signup_id = request.form.get('wiki_signup_textbox_1', )
        signup_password_1 = request.form.get('wiki_signup_textbox_2', )
        signup_password_2 = request.form.get('wiki_signup_textbox_3', )
        if ((not signup_password_1) and (not signup_password_2)):
            return response.redirect('/error/')
        if (signup_password_1 != signup_password_2):
            return response.redirect('/error/')
        if re.search('(?:[^A-Za-z0-9가-힣])', signup_id):
            return response.redirect('/error/')
        if ((len(signup_id) > 24) or (len(signup_id) < 3)):
            return response.redirect('/error/')
        id_check = (await db.execute('select id from mbr where id = ?', [signup_id]))
        id_check = (await id_check.fetchall())
        if id_check:
            return response.redirect('/error/')
        encode_password = (await password_encode(signup_password_1, signup_id))
        first_check = (await db.execute('select * from mbr limit 1'))
        first_check = (await first_check.fetchall())
        if (not first_check):
            (await db.execute('insert into mbr (id, pw, acl, date, email) values (?, ?, ?, ?, ?)', [signup_id, encode_password, 'owner', (await date_time()), ]))
            (await db.execute('insert into mbr_log (name, ip, ua, today) values (?, ?, ?, ?)', [signup_id, '0', '0', (await date_time())]))
            (await db.commit())
            return response.redirect('/member/login')
        else:
            (await db.execute('insert into mbr (id, pw, acl, date, email) values (?, ?, ?, ?, ?)', [signup_id, encode_password, 'member', (await date_time()), ]))
            (await db.execute('insert into mbr_log (name, ip, ua, today) values (?, ?, ?, ?)', [signup_id, '0', '0', (await date_time())]))
            (await db.commit())
            return response.redirect('/member/login')
    return jinja.render('index.html', request, wiki_set=(await wiki_set(request, 0)), data='\n            <form method="post">\n                <input type="text" placeholder="아이디" class="wiki_textbox" name="wiki_signup_textbox_1">\n                <hr class="wiki_hr">\n                <input type="password" placeholder="비밀번호" class="wiki_textbox" name="wiki_signup_textbox_2">\n                <hr class="wiki_hr">\n                <input type="password" placeholder="비밀번호 확인" class="wiki_textbox" name="wiki_signup_textbox_3">\n                <hr class="wiki_hr">\n                <button type="submit" class="wiki_button" name="wiki_signup_button_1">확인</button>\n            </form>\n        ', title='계정 만들기', sub=0, menu=0)