-
Notifications
You must be signed in to change notification settings - Fork 2
/
DeLorean.py
executable file
·54 lines (33 loc) · 1.44 KB
/
DeLorean.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sqlite3 as lite
from datetime import datetime, date
import flask , flask.views
from flask import request
import json
app = flask.Flask(__name__)
class View(flask.views.MethodView):
def get(self):
con = lite.connect('fluxCapacitor.db',detect_types=lite.PARSE_DECLTYPES)
with con:
cur = con.cursor()
cur.execute("SELECT * FROM logs")
rows = cur.fetchall()
haxx = "all the stuff in the table" + "<br>\n"
for row in rows:
haxx = haxx + row[1] + ", " + row[2] + ", " + str(row[3]) + "<br>\n"
return haxx
def put(self):
parsed_json = json.loads(request.data)
temp = datetime.now()
con = lite.connect('fluxCapacitor.db',detect_types=lite.PARSE_DECLTYPES)
with con:
cur = con.cursor()
cur.execute("INSERT INTO logs(memberName,action,timestamp) VALUES (?,?,?);",(parsed_json['who'],parsed_json['what'],temp))
print "'Put " + parsed_json['who'] + "' in logs with action '" + parsed_json['what'] + "' at time " + str(temp)
return "nothing"
app.add_url_rule('/',view_func=View.as_view('main'))
app.debug = True
app.run(host='0.0.0.0',port=5001)
# cur.execute("DROP TABLE IF EXISTS logs")
# cur.execute("CREATE TABLE logs (id integer primary key, memberName text, action text, [timestamp] timestamp)")