Complete server.py

This commit is contained in:
Ceda EI 2019-01-22 17:46:00 +05:30
parent d7c4f7e14c
commit f88e29426d
1 changed files with 16 additions and 3 deletions

View File

@ -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__)