Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. <form method="POST" action="/">
  2. <h4>Search for Your Device</h4>
  3. <p>Enter the Asset Tag of the device - On the back sticker or in small print at the bottom of the lock screen.</p>
  4. <p><input type = "text" name = "Name" /></p>
  5. <p><input type = "submit" value = "submit" /></p>
  6. </form>
  7.  
  8. @app.route('/', methods=["GET","POST"])
  9. def homepage():
  10. try:
  11. if request.method == "POST":
  12. #API URL
  13. JSS_API = 'https://private_url.com'
  14. #Pre-Defined username and password
  15. username = 'username'
  16. password = 'password'
  17.  
  18. #Ask User for the Asset tag
  19. asset_tag = request.form
  20. New_JSS_API = JSS_API + asset_tag
  21.  
  22. #Disables Warnings about SSL
  23. requests.packages.urllib3.disable_warnings()
  24.  
  25. JSS_Asset_Response = requests.get(New_JSS_API, auth=(username, password), verify=False, headers={'Accept': 'application/json'})
  26.  
  27. JSS_json = JSS_Asset_Response.json()
  28.  
  29. email_dict = {}
  30. for item in JSS_json['mobile_devices']:
  31. email_dict["Stu_name".format(item)]=item['realname']
  32. #Can call the dictionary value by doing the following:
  33. stu_name = email_dict['Stu_name']
  34. return stu_name
  35.  
  36. return render_template("index.html")
  37. except Exception as e:
  38. return(str(e))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement