@app.route('/revert/<name:string>', methods=['POST', 'GET'])
async def wiki_revert(request, name):
    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')))
    args = RequestParameters()
    num = request.args.get('num', '1')
    dbdata = (await db.execute('select data from doc_his order by cast(id as integer) desc limit 1'))
    dbdata = (await dbdata.fetchall())
    current = dbdata[0][0]
    data_get = (await db.execute('select data from doc_his where id = ?', [num]))
    data_get = (await data_get.fetchall())
    data_get = data_get[0][0]
    if (request.method == 'POST'):
        send = request.form.get('wiki_revert_textbox_2', '')
        data_get = re.sub('\n', '<br>', data_get)
        (await db.execute('update doc set data = ? where title = ?', [data_get, name]))
        (await db.commit())
        (await history_add(name, data_get, (await date_time()), (await user_name(request)), send, str((len(current) - len(data_get)))))
        return response.redirect(('/w/' + name))
    if data_get:
        return jinja.render('index.html', request, wiki_set=(await wiki_set(request, name)), data=(('\n                <form method="post">\n                    <textarea rows="25" class="wiki_textarea" name="wiki_revert_textarea_1" readonly>' + data_get) + '</textarea>\n                    <hr class="wiki_hr">\n                    <input type="text" placeholder="요약" class="wiki_textbox" name="wiki_revert_textbox_2">\n                    <hr class="wiki_hr">\n                    <button type="submit" class="wiki_button" name="wiki_revert_button_1">확인</button>\n                </form>\n            '), title=name, sub=(('r' + num) + ' 복구'), menu=[[('w/' + name), '문서']])
    else:
        return response.redirect('/error/')
@app.route('/revert/<name:string>', methods=['POST', 'GET'])
async def wiki_revert(request, name):
    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')))
    args = RequestParameters()
    num = request.args.get('num', '1')
    dbdata = (await db.execute('select data from doc_his order by cast(id as integer) desc limit 1'))
    dbdata = (await dbdata.fetchall())
    current = dbdata[0][0]
    data_get = (await db.execute('select data from doc_his where id = ?', [num]))
    data_get = (await data_get.fetchall())
    data_get = data_get[0][0]
    if (request.method == 'POST'):
        send = request.form.get('wiki_revert_textbox_2', )
        data_get = re.sub('\n', '<br>', data_get)
        (await db.execute('update doc set data = ? where title = ?', [data_get, name]))
        (await db.commit())
        (await history_add(name, data_get, (await date_time()), (await user_name(request)), send, str((len(current) - len(data_get)))))
        return response.redirect(('/w/' + name))
    if data_get:
        return jinja.render('index.html', request, wiki_set=(await wiki_set(request, name)), data=(('\n                <form method="post">\n                    <textarea rows="25" class="wiki_textarea" name="wiki_revert_textarea_1" readonly>' + data_get) + '</textarea>\n                    <hr class="wiki_hr">\n                    <input type="text" placeholder="요약" class="wiki_textbox" name="wiki_revert_textbox_2">\n                    <hr class="wiki_hr">\n                    <button type="submit" class="wiki_button" name="wiki_revert_button_1">확인</button>\n                </form>\n            '), title=name, sub=(('r' + num) + ' 복구'), menu=[[('w/' + name), '문서']])
    else:
        return response.redirect('/error/')