-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
54 lines (47 loc) · 1.5 KB
/
main.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
48
49
50
51
52
53
54
import flask
from Hack20Firestore import addUser, getUser, getUserMatches
app = flask.Flask(__name__)
@app.route('/')
def home():
return '''<h1> Test </h1>'''
@app.route('/api/v1/addUser')
def api_addUser():
if 'email' in flask.request.args:
email = str(flask.request.args['email'])
else:
email = None
if 'name' in flask.request.args:
Name = str(flask.request.args['name'])
else:
Name = None
if 'classes' in flask.request.args:
Classes = flask.request.args.getlist('classes')
else:
Classes = None
if 'interests' in flask.request.args:
Interests = flask.request.args.getlist('interests')
else:
Interests = None
if 'year' in flask.request.args:
Year = int(flask.request.args['year'])
else:
Year = None
if 'major' in flask.request.args:
Major = str(flask.request.args['major'])
else:
Major = None
addUser(email=email, name=Name, classes=Classes, interests=Interests, year=Year, major=Major)
return('User added to DB!')
@app.route('/api/v1/getUser')
def api_getUser():
if 'email' in flask.request.args:
return flask.jsonify(getUser(flask.request.args['email']))
else:
return "You Did Not Pass in an E-Mail!"
@app.route('/api/v1/getUserMatches')
def api_getUserMatches():
if 'email' in flask.request.args:
return flask.jsonify(getUserMatches(flask.request.args['email']))
else:
return "You Did Not Pass in an E-Mail!"
app.run()