Complete server.py
This commit is contained in:
parent
d7c4f7e14c
commit
f88e29426d
|
@ -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__)
|
||||
|
|
Loading…
Reference in New Issue