forked from bvabhishek/api-security
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab3.py
More file actions
35 lines (34 loc) · 1.41 KB
/
lab3.py
File metadata and controls
35 lines (34 loc) · 1.41 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
import flask
from flask import request, jsonify
app = flask.Flask(__name__)
app.config["DEBUG"] = True
@app.route('/', methods=['POST'])
def api_home():
return "paths '/api/v1/changeUserSettings'"
@app.route('/api/v1/changeUserSettings', methods=['POST'])
def api_cards():
if 'username' in request.args:
name = request.args['name']
else:
return "Error: No username field provided. Please specify an accountType,name,firstname and adress."
if 'name' in request.args:
name = request.args['name']
else:
return "Error: No name field provided. Please specify an accountType,name,firstname and adress."
if 'firstname' in request.args:
name = request.args['name']
else:
return "Error: No firstname field provided. Please specify an accountType,name,firstname and adress."
if 'adress' in request.args:
name = request.args['name']
else:
return "Error: No adress field provided. Please specify an accountType,name,firstname and adress."
if 'accountType' in request.args:
type = request.args['accountType']
else:
return "Error: No type field provided. Please specify an accountType,name,firstname and adress. The type can be either user or reader"
if type == 'admin':
return "Good job!! Welcome to admin portal, Yo The BOSS!!!"
else:
return "account settings saved"
app.run(host="0.0.0.0",port="5008")