From f88e29426d232dd01023f8fb9a78bb96711a8cba Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Tue, 22 Jan 2019 17:46:00 +0530 Subject: [PATCH] Complete server.py --- bot/server.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/bot/server.py b/bot/server.py index 1bf62bf..fc32f3f 100644 --- a/bot/server.py +++ b/bot/server.py @@ -1,15 +1,28 @@ #!/usr/bin/env python3 -from flask import Flask +from flask import Flask, request import sqlite3 def get(db): - pass + cursor = db.cursor() + query = "SELECT * FROM messages ORDER BY ROWID" + cursor.execute(query) + text = "" + for row in cursor: + text += row[0] + "\n" + cursor.execute("DELETE FROM messages") + db.commit() + return text def post(db): - pass + message = request.form['message'] + cursor = db.cursor() + query = 'INSERT INTO messages values(?)' + cursor.execute(query, (message,)) + db.commit() + return "" app = Flask(__name__)