-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAlert_App.py
More file actions
51 lines (37 loc) · 1.14 KB
/
Alert_App.py
File metadata and controls
51 lines (37 loc) · 1.14 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
import datetime
from Alert_Database import Alert_Database
from flask import Flask
import ast
import requests
ad = Alert_Database({})
app = Flask(__name__)
# Returns 10 reminders in database which come up next.
@app.route('/')
def __init__():
return ad.scan_reminders()
@app.route('/get')
def get():
return str(ad.get_reminders())
@app.route('/set/<string:time>/<string:text>')
def set(time, text):
# error check/formatting check
try:
test_time = datetime.datetime.strptime(time, "%H:%M:%S")
except ValueError:
# for testing purposes
print("Sorry, the time you gave is not a valid time.")
# Not sure how to test the text for validity.
# add reminder - have yet to test
return ad.new_reminder(time, text)
# nothing to return
@app.route('/drop/<int:numID>')
def drop(numID):
# identify the reminder by the number id it was given aka numID
# did not test yet!!
if isinstance(numID, int):
return ad.delete_reminder(numID)
else:
response = "I'm sorry. ", numID, " is not a valid reminder code."
return response
if __name__ == "__main__":
app.run(debug=True)