@app.route('/discuss/<name:string>/<num:int>', methods=['POST', 'GET'])
async def wiki_discuss_thread(request, name, num):
    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')))
    data = ''
    thread_list = (await db.execute('select id, data, date, ip, block, top from dis_log where code = ? and doc = ?', [num, name]))
    thread_list = (await thread_list.fetchall())
    thread_user = (await db.execute("select ip from dis_log where id = '1'"))
    thread_user = (await thread_user.fetchall())
    if (not thread_list):
        return response.redirect('/error/')
    for thread_data in thread_list:
        if ((thread_data[3] != '1') and (thread_user[0][0] == thread_data[3])):
            data += (((((((('\n                <div class="wiki_thread_table_first">\n                    <div class="wiki_thread_table_top">\n                        ' + thread_data[0]) + ' ') + thread_data[3]) + ' ') + thread_data[4]) + '\n                    </div>\n                    <div class="wiki_thread_table_bottom">\n                        ') + thread_data[1]) + '\n                    </div>\n                </div>\n            ')
        elif ((thread_data[3] != '1') and (thread_user[0][0] != thread_data[3])):
            data += (((((((('\n                <div class="wiki_thread_table_other">\n                    <div class="wiki_thread_table_top">\n                        ' + thread_data[0]) + ' ') + thread_data[3]) + ' ') + thread_data[4]) + '\n                    </div>\n                    <div class="wiki_thread_table_bottom">\n                        ') + thread_data[1]) + '\n                    </div>\n                </div>\n            ')
        elif ((thread_data[3] == '1') and (thread_user[0][0] == thread_data[3])):
            data += (((((('\n                <div class="wiki_thread_table_first_blind">\n                    <div class="wiki_thread_table_top">\n                        ' + thread_data[0]) + ' ') + thread_data[3]) + ' ') + thread_data[2]) + '\n                    </div>\n                    <div class="wiki_thread_table_bottom">\n                        블라인드된 스레드입니다.\n                        </div>\n                </div>\n            ')
        else:
            data += (((((('\n                <div class="wiki_thread_table_other_blind">\n                    <div class="wiki_thread_table_top">\n                        ' + thread_data[0]) + ' ') + thread_data[3]) + ' ') + thread_data[2]) + '\n                    </div>\n                    <div class="wiki_thread_table_bottom">\n                        블라인드된 스레드입니다.\n                        </div>\n                </div>\n            ')
    if (request.method == 'POST'):
        textarea_data = request.form.get('wiki_thread_textarea_1')
        if (not textarea_data):
            return response.redirect('/error/')
        discuss_num = (await db.execute('select id from dis_log where doc = ? order by id desc', [name]))
        discuss_num = (await discuss_num.fetchall())
        discuss_num = (int(discuss_num[0][0]) + 1)
        (await db.execute("insert into dis_log (id, data, date, ip, block, top, code, doc) values (?, ?, ?, ?, '0', '0', ?, ?)", [discuss_num, textarea_data, (await date_time()), (await user_name(request)), num, name]))
        (await db.commit())
        return response.redirect(((('/discuss/' + name) + '/') + str(num)))
    return jinja.render('index.html', request, wiki_set=(await wiki_set(request, name)), data=(data + '\n            <form method="post">\n                <textarea class="wiki_textarea" name="wiki_thread_textarea_1"></textarea>\n                <hr class="wiki_hr">\n                <button type="submit" class="wiki_button" name="wiki_thread_button_1">확인</button>\n            </form>\n        '), title=name, sub='토론', menu=[[('w/' + name), '문서']])
@app.route('/discuss/<name:string>/<num:int>', methods=['POST', 'GET'])
async def wiki_discuss_thread(request, name, num):
    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')))
    data = 
    thread_list = (await db.execute('select id, data, date, ip, block, top from dis_log where code = ? and doc = ?', [num, name]))
    thread_list = (await thread_list.fetchall())
    thread_user = (await db.execute("select ip from dis_log where id = '1'"))
    thread_user = (await thread_user.fetchall())
    if (not thread_list):
        return response.redirect('/error/')
    for thread_data in thread_list:
        if ((thread_data[3] != '1') and (thread_user[0][0] == thread_data[3])):
            data += (((((((('\n                <div class="wiki_thread_table_first">\n                    <div class="wiki_thread_table_top">\n                        ' + thread_data[0]) + ' ') + thread_data[3]) + ' ') + thread_data[4]) + '\n                    </div>\n                    <div class="wiki_thread_table_bottom">\n                        ') + thread_data[1]) + '\n                    </div>\n                </div>\n            ')
        elif ((thread_data[3] != '1') and (thread_user[0][0] != thread_data[3])):
            data += (((((((('\n                <div class="wiki_thread_table_other">\n                    <div class="wiki_thread_table_top">\n                        ' + thread_data[0]) + ' ') + thread_data[3]) + ' ') + thread_data[4]) + '\n                    </div>\n                    <div class="wiki_thread_table_bottom">\n                        ') + thread_data[1]) + '\n                    </div>\n                </div>\n            ')
        elif ((thread_data[3] == '1') and (thread_user[0][0] == thread_data[3])):
            data += (((((('\n                <div class="wiki_thread_table_first_blind">\n                    <div class="wiki_thread_table_top">\n                        ' + thread_data[0]) + ' ') + thread_data[3]) + ' ') + thread_data[2]) + '\n                    </div>\n                    <div class="wiki_thread_table_bottom">\n                        블라인드된 스레드입니다.\n                        </div>\n                </div>\n            ')
        else:
            data += (((((('\n                <div class="wiki_thread_table_other_blind">\n                    <div class="wiki_thread_table_top">\n                        ' + thread_data[0]) + ' ') + thread_data[3]) + ' ') + thread_data[2]) + '\n                    </div>\n                    <div class="wiki_thread_table_bottom">\n                        블라인드된 스레드입니다.\n                        </div>\n                </div>\n            ')
    if (request.method == 'POST'):
        textarea_data = request.form.get('wiki_thread_textarea_1')
        if (not textarea_data):
            return response.redirect('/error/')
        discuss_num = (await db.execute('select id from dis_log where doc = ? order by id desc', [name]))
        discuss_num = (await discuss_num.fetchall())
        discuss_num = (int(discuss_num[0][0]) + 1)
        (await db.execute("insert into dis_log (id, data, date, ip, block, top, code, doc) values (?, ?, ?, ?, '0', '0', ?, ?)", [discuss_num, textarea_data, (await date_time()), (await user_name(request)), num, name]))
        (await db.commit())
        return response.redirect(((('/discuss/' + name) + '/') + str(num)))
    return jinja.render('index.html', request, wiki_set=(await wiki_set(request, name)), data=(data + '\n            <form method="post">\n                <textarea class="wiki_textarea" name="wiki_thread_textarea_1"></textarea>\n                <hr class="wiki_hr">\n                <button type="submit" class="wiki_button" name="wiki_thread_button_1">확인</button>\n            </form>\n        '), title=name, sub='토론', menu=[[('w/' + name), '문서']])