-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.py
More file actions
62 lines (51 loc) · 1.83 KB
/
hello.py
File metadata and controls
62 lines (51 loc) · 1.83 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
from flask import Flask
from flask import request
import datetime, json
import os
app = Flask(__name__)
@app.route('/', methods=['POST'])
def api():
time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
requestingUserId = request.form['userId']
f = request.files['photo']
f.save('/root/memoreyes-server/uploaded_image.jpg')
return json.dumps({'success':'true','time':time})
# returns a complete set of data for a given user
def read_user_data(userId):
with open(userId+'.json', 'r') as dataFile:
data = json.load(dataFile)
return data
# writes a full set of data for a given user
def write_user_data(userId, newData):
with open(userId+'.json', 'w') as dataFile:
json.dump(newData, dataFile)
return True
# adds a person to a user's data set
def add_person(userId, personsName, personsRelationship):
data = read_user_data(userId)
data['people'][personsName] = personsRelationship
write_user_data(userId, data)
return True
# checks to see if a person is in a user's data set by name
def check_for_person(userId, personsName):
data = read_user_data(userId)
if personsName in data['people']:
return True
# adds a drug to a user's data set
def add_drug(userId, drugName, drugInstructions):
data = read_user_data(userId)
data['drugs'][drugName] = drugInstructions
write_user_data(userId, data)
return True
# checks to see if a drug is in a user's data set by name
def check_for_drug(userId, drugName):
data = read_user_data(userId)
if drugName in data['drugs']:
return True
# Debug DB
# dataObject = read_user_data('123456')
# print(json.dumps(dataObject, indent=2, separators=(',', ': ')))
def speak_name(personsName):
with open('DATA.txt','w') as dataFile:
json.dump(personsName, dataFile)
os.system('node texttospeechv1.js')