-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
128 lines (105 loc) · 6 KB
/
app.py
File metadata and controls
128 lines (105 loc) · 6 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
from flask import Flask, render_template, redirect, request
from time import sleep
from random import randint, seed
import datetime
reports = [['Brittany B', 'Southport Beach', 'Whale', 'Beached whale, 10 feet from the current water level', 0, '', 0], ['Chris F', 'Eastport Beach', 'Stingray', 'Stringray on the shore, one person has been stung', 2, 'Eastport Stingray',1], ['Manda Mandalay', 'Northport Beach', 'Seal', 'Family of seals, people are getting close to the animals', 0, '',2], ['Lexi Alexander', 'Oak Street Beach', 'Asian Carp', 'Two (I think they are asian carp) fish on the lakefront path, kids are poking them, it looks like they are dead', 2, 'Oak Street Carp', 3], ['Nick Jonas', 'Oak Street Beach', 'Asian Carp','Fish on the path, blocking human traffic. They look dead', 0, '', 4]]
#last integer in reports 0 = unprocessed, 1 = archived, 2 = in a new event, 3 = in an existing event, 4 = event completed]
events = [[0,'Southport Bached Whale', 18,[('Erik Rick',datetime.datetime.now(),'Arrived at scene, saw two beached whales, called for professional help')]]]
app = Flask(__name__)
@app.route('/')
def welcome():
return render_template('welcome.html')
@app.route('/fileReport')
def fileReport():
return render_template('fileReport.html')
@app.route('/reportSuccess',methods=['POST','GET'])
def reportSuccess():
# global reports
# if request.method == 'POST':
# report = [request.form['name'], request.form['location'], request.form['type'], request.form['description'], 0, '',len(reports)]
# reports.append(report)
return render_template('reportSuccess.html')
@app.route('/signIn')
def signIn():
return render_template('signIn.html')
@app.route('/signInError')
def signInError():
errMsg = 1
return render_template('signIn.html',errMsg=errMsg)
@app.route('/homepage',methods=['POST','GET'])
def homepage(errMsg=0):
users = [('john.doe@noaa.org', 'password'),('volunteer@volunteer.org', '123456'),('professional@professional.org','asdfjkl')]
if request.method == 'POST':
username = request.form['email']
password = request.form['password']
for user in users:
if user[0] == username:
if user[1] == password:
if "@noaa.org" in user[0]:
return redirect('/homepageNOAA')
return render_template('homepage.html')
return redirect('/signInError')
return render_template('homepage.html', errMsg=errMsg)
@app.route('/homepageNOAA')
def homepageNOAA():
return render_template('homepageNOAA.html')
@app.route('/homepageNOAA/pendingReports')
def pendingReports():
reports = [['Brittany B', 'Southport Beach', 'Whale', 'Beached whale, 10 feet from the current water level', 0, '', 0], ['Chris F', 'Eastport Beach', 'Stingray', 'Stringray on the shore, one person has been stung', 2, 'Eastport Stingray',1], ['Manda Mandalay', 'Northport Beach', 'Seal', 'Family of seals, people are getting close to the animals', 0, '',2], ['Lexi Alexander', 'Oak Street Beach', 'Asian Carp', 'Two (I think they are asian carp) fish on the lakefront path, kids are poking them, it looks like they are dead', 2, 'Oak Street Carp', 3], ['Nick Jonas', 'Oak Street Beach', 'Asian Carp','Fish on the path, blocking human traffic. They look dead', 0, '', 4]]
return render_template('pendingReports.html', data=reports)
@app.route('/homepageNOAA/submittedReports')
def submittedReports():
return render_template('submittedReports.html', data=reports)
@app.route('/classify/<int:index>', methods=['POST','GET'])
def classify(index):
reports = [['Brittany B', 'Southport Beach', 'Whale', 'Beached whale, 10 feet from the current water level', 0, '', 0], ['Chris F', 'Eastport Beach', 'Stingray', 'Stringray on the shore, one person has been stung', 2, 'Eastport Stingray',1], ['Manda Mandalay', 'Northport Beach', 'Seal', 'Family of seals, people are getting close to the animals', 0, '',2], ['Lexi Alexander', 'Oak Street Beach', 'Asian Carp', 'Two (I think they are asian carp) fish on the lakefront path, kids are poking them, it looks like they are dead', 2, 'Oak Street Carp', 3], ['Nick Jonas', 'Oak Street Beach', 'Asian Carp','Fish on the path, blocking human traffic. They look dead', 0, '', 4]]
print(request.form)
print(reports)
if request.method == 'POST':
if 'escalate' in request.form:
reports[index][4] = 2
reports[index][5] = request.form['escalateName']
elif 'delete' in request.form:
reports[index][4] = 1
elif 'add' in request.form:
reports[index][4] = 3
reports[index][5] = request.form['add']
print(reports)
return render_template('submittedReports.html', data=reports)
# return redirect('/homepageNOAA/submittedReports')
@app.route('/messageBoard', methods=['POST','GET'])
def messageBoard():
global events
if request.method == 'POST':
print(request.form)
newMessage = (request.form['person'],datetime.datetime.now(),request.form['comment'])
events[int(request.form['eventIndex'])][3].insert(0,newMessage)
event = events[int(request.form['eventIndex'])]
return render_template('messageBoard.html',event = event)
event = events[0]
return render_template('messageBoard.html', event = event)
@app.route('/homepage/mySchedule')
def mySchedule():
return render_template('mySchedule.html')
@app.route('/homepage/eventList')
def eventList():
return render_template('eventList.html')
@app.route('/homepage/eventMap')
def eventMap():
return render_template('eventMap.html')
@app.route('/homepage/settings')
def settings():
return render_template('settings.html')
@app.route('/logoutSuccess')
def logoutSuccess():
seed()
randomTimeout = randint(1,5)
if randomTimeout%5 == 0:
sleep(2)
errMsg = 1
homepage(errMsg)
return render_template('logoutSuccess.html')
@app.route('/portfolio')
def portfolio():
return render_template('indexOld.html')
if __name__ == '__main__': app.run(debug=True)