Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form method="POST" action="/">
- <h4>Search for Your Device</h4>
- <p>Enter the Asset Tag of the device - On the back sticker or in small print at the bottom of the lock screen.</p>
- <p><input type = "text" name = "Name" /></p>
- <p><input type = "submit" value = "submit" /></p>
- </form>
- @app.route('/', methods=["GET","POST"])
- def homepage():
- try:
- if request.method == "POST":
- #API URL
- JSS_API = 'https://private_url.com'
- #Pre-Defined username and password
- username = 'username'
- password = 'password'
- #Ask User for the Asset tag
- asset_tag = request.form
- New_JSS_API = JSS_API + asset_tag
- #Disables Warnings about SSL
- requests.packages.urllib3.disable_warnings()
- JSS_Asset_Response = requests.get(New_JSS_API, auth=(username, password), verify=False, headers={'Accept': 'application/json'})
- JSS_json = JSS_Asset_Response.json()
- email_dict = {}
- for item in JSS_json['mobile_devices']:
- email_dict["Stu_name".format(item)]=item['realname']
- #Can call the dictionary value by doing the following:
- stu_name = email_dict['Stu_name']
- return stu_name
- return render_template("index.html")
- except Exception as e:
- return(str(e))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement