app post msg def add_msg post_id post_id_generator encode post_header

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
@app.post('/msg')
def add_msg():
post_id = post_id_generator().encode()
post_header = Bottle.request.forms.get('post-header').encode()
post_content = Bottle.request.forms.get('post-content').encode()
date = datetime.date.today().strftime('%d.%m.%Y').encode()
time = datetime.datetime.now().time().strftime('%H.%M.%S').encode()
connection = sqlite3.connect('bottle_db')
cursor = connection.cursor()
data = (date, time, post_id, post_header, post_content)
cursor.execute('INSERT INTO main VALUES (?,?,?,?,?)', data)
connection.commit()
connection.close()
return post_header