initial commit
This commit is contained in:
parent
5a114c546f
commit
5e2fc16cc3
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*__pycache
|
||||
.vscode
|
7
notification.py
Normal file → Executable file
7
notification.py
Normal file → Executable file
@ -34,11 +34,8 @@ class Notification:
|
||||
:param content str:
|
||||
This is a multi-line body of text. Each line is a paragraph, server
|
||||
implementations are free to word wrap them as they see fit.
|
||||
The body mayfrom gi.repository import GLib
|
||||
import dbus
|
||||
from dbus.mainloop.glib import DBusGMainLoop
|
||||
functionality may not be implemented by the notification
|
||||
server, conforming clients should check if it is available before using
|
||||
The body functionality may not be implemented by the notification
|
||||
server, conforming clients should check if it is available before usings
|
||||
it (see the GetCapabilities message in Protocol). An implementation is
|
||||
free to ignore any requested by the client. As an example one possible
|
||||
rendering of actions would be as buttons in the notification popup.
|
||||
|
36
serveur.py
Normal file → Executable file
36
serveur.py
Normal file → Executable file
@ -1,4 +1,5 @@
|
||||
#!/bin/python
|
||||
import hashlib
|
||||
import sqlite3
|
||||
import secrets
|
||||
import time
|
||||
@ -11,7 +12,6 @@ socketio = flask_socketio.SocketIO(app)
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
||||
def first_run():
|
||||
"""
|
||||
create databases
|
||||
@ -135,14 +135,14 @@ def get_notifications():
|
||||
token = request.values.get("token")
|
||||
con = sqlite3.connect("database.db")
|
||||
cur = con.cursor()
|
||||
notifications = cur.execute("SELECT title,content \
|
||||
notifications = cur.execute("SELECT * \
|
||||
FROM NOTIFICATION \
|
||||
WHERE token=?",
|
||||
(token, )).fetchall()
|
||||
data = {"status": "ok"}
|
||||
data["notifications"] = []
|
||||
for notification in notifications:
|
||||
data["notifications"].append({"title": notification[0],"content": notification[1]})
|
||||
data["notifications"].append()
|
||||
return data, 200
|
||||
|
||||
|
||||
@ -158,26 +158,31 @@ def get_notification_by_id(notifid):
|
||||
con = sqlite3.connect("database.db")
|
||||
cur = con.cursor()
|
||||
if notifid == -1:
|
||||
notifications = cur.execute("SELECT title,content \
|
||||
notifications = cur.execute("SELECT * \
|
||||
FROM NOTIFICATION \
|
||||
WHERE token=?\
|
||||
ORDER BY id DESC \
|
||||
LIMIT 1",
|
||||
(token,)).fetchone()
|
||||
else:
|
||||
notifications = cur.execute("SELECT title,content \
|
||||
notifications = cur.execute("SELECT * \
|
||||
FROM NOTIFICATION \
|
||||
WHERE token=? AND id=?",
|
||||
(token, notifid)).fetchone()
|
||||
|
||||
return {"status": "ok",
|
||||
"notifications": {"title": notifications[0],
|
||||
"content": notifications[1]
|
||||
}
|
||||
"notifications": notifications
|
||||
}, 200
|
||||
|
||||
###############################################################################
|
||||
|
||||
def clipFromArray(clip):
|
||||
return {"id": clip[0],
|
||||
"timestamp": clip[1],
|
||||
"deviceName": clip[2],
|
||||
"token": clip[3],
|
||||
"content": clip[3]}
|
||||
|
||||
|
||||
@app.route("/clipboard", methods=['PUT'])
|
||||
def add_clipboard():
|
||||
@ -217,11 +222,11 @@ def get_clipboard():
|
||||
token = request.values.get("token")
|
||||
con = sqlite3.connect("database.db")
|
||||
cur = con.cursor()
|
||||
clipboard = cur.execute("SELECT content \
|
||||
clipboard = cur.execute("SELECT * \
|
||||
FROM CLIPBOARD \
|
||||
WHERE token=?",
|
||||
WHERE token=?",
|
||||
(token, )).fetchall()
|
||||
|
||||
clipboard = [clipFromArray(clip) for clip in clipboard]
|
||||
return {"status": "ok", "clipboard": clipboard}, 200
|
||||
|
||||
|
||||
@ -237,19 +242,18 @@ def get_clipboard_by_id(clipid):
|
||||
con = sqlite3.connect("database.db")
|
||||
cur = con.cursor()
|
||||
if clipid == -1:
|
||||
clipboard = cur.execute("SELECT content \
|
||||
clipboard = cur.execute("SELECT * \
|
||||
FROM CLIPBOARD \
|
||||
WHERE token=? \
|
||||
ORDER BY id DESC \
|
||||
LIMIT 1",
|
||||
(token,)).fetchone()
|
||||
else:
|
||||
clipboard = cur.execute("SELECT content \
|
||||
clipboard = cur.execute("SELECT * \
|
||||
FROM CLIPBOARD \
|
||||
token=? AND id=?",
|
||||
WHERE token=? AND id=?",
|
||||
(token, clipid)).fetchone()
|
||||
|
||||
return {"status": "ok", "clipboard": clipboard[0]}, 200
|
||||
return {"status": "ok", "clipboard": clipFromArray(clipboard)}, 200
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user