@app.route('/edit/<name:string>', methods=['POST', 'GET'])
async def wiki_edit(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')))
    data_get = (await db.execute('select data from doc where title = ? ', [name]))
    data_get = (await data_get.fetchall())
    data = ''
    olddata = ''
    if data_get:
        data = data_get[0][0]
        olddata = data
    if (request.method == 'POST'):
        data = request.form.get('wiki_edit_textarea_1', '')
        send = request.form.get('wiki_edit_textbox_1', '')
        if data_get:
            if (data_get[0][0] == data):
                return response.redirect(('/w/' + name))
            else:
                data = re.sub('\n', '<br>', data)
                (await db.execute('update doc set data = ? where title = ?', [data, name]))
                (await db.commit())
                (await history_add(name, data, (await date_time()), (await user_name(request)), send, str((len(data) - len(olddata)))))
                return response.redirect(('/w/' + name))
        else:
            data = re.sub('\n', '<br>', data)
            (await db.execute('insert into doc (title, data) values (?, ?)', [name, data]))
            (await db.commit())
            (await history_add(name, data, (await date_time()), (await user_name(request)), send, str(len(data))))
            return response.redirect(('/w/' + name))
    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_edit_textarea_1">' + html.escape(re.sub('<br>', '\n', data))) + '</textarea>\n                    <hr class="wiki_hr">\n                    <input type="text" placeholder="요약" class="wiki_textbox" name="wiki_edit_textbox_1">\n                    <hr class="wiki_hr">\n                    <button type="submit" class="wiki_button" name="wiki_edit_button_1">저장</button>\n                </form>\n            '), title=name, sub='편집', menu=[[('delete/' + name), '삭제'], [('move/' + name), '이동'], [('w/' + name), '문서']])
@app.route('/edit/<name:string>', methods=['POST', 'GET'])
async def wiki_edit(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')))
    data_get = (await db.execute('select data from doc where title = ? ', [name]))
    data_get = (await data_get.fetchall())
    data = 
    olddata = 
    if data_get:
        data = data_get[0][0]
        olddata = data
    if (request.method == 'POST'):
        data = request.form.get('wiki_edit_textarea_1', )
        send = request.form.get('wiki_edit_textbox_1', )
        if data_get:
            if (data_get[0][0] == data):
                return response.redirect(('/w/' + name))
            else:
                data = re.sub('\n', '<br>', data)
                (await db.execute('update doc set data = ? where title = ?', [data, name]))
                (await db.commit())
                (await history_add(name, data, (await date_time()), (await user_name(request)), send, str((len(data) - len(olddata)))))
                return response.redirect(('/w/' + name))
        else:
            data = re.sub('\n', '<br>', data)
            (await db.execute('insert into doc (title, data) values (?, ?)', [name, data]))
            (await db.commit())
            (await history_add(name, data, (await date_time()), (await user_name(request)), send, str(len(data))))
            return response.redirect(('/w/' + name))
    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_edit_textarea_1">' + html.escape(re.sub('<br>', '\n', data))) + '</textarea>\n                    <hr class="wiki_hr">\n                    <input type="text" placeholder="요약" class="wiki_textbox" name="wiki_edit_textbox_1">\n                    <hr class="wiki_hr">\n                    <button type="submit" class="wiki_button" name="wiki_edit_button_1">저장</button>\n                </form>\n            '), title=name, sub='편집', menu=[[('delete/' + name), '삭제'], [('move/' + name), '이동'], [('w/' + name), '문서']])