Guest User

Untitled

a guest
Nov 18th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. Not Found
  2. The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
  3.  
  4. vagrant@vagrant-ubuntu-trusty-32:~$ curl 'http://127.0.0.1:5000'
  5. curl: (7) Failed to connect to 127.0.0.1 port 5000: Connection refused
  6.  
  7. #THIS IS A WEBSERVER FOR DEMONSTRATING THE TYPES OF RESPONSES WE SEE FROM AN API ENDPOINT
  8. from flask import Flask
  9. app = Flask(__name__)
  10.  
  11. #GET REQUEST
  12.  
  13. @app.route('/readHello')
  14. def getRequestHello():
  15. return "Hi, I got your GET Request!"
  16.  
  17. #POST REQUEST
  18. @app.route('/createHello', methods = ['POST'])
  19. def postRequestHello():
  20. return "I see you sent a POST message :-)"
  21. #UPDATE REQUEST
  22. @app.route('/updateHello', methods = ['PUT'])
  23. def updateRequestHello():
  24. return "Sending Hello on an PUT request!"
  25.  
  26. #DELETE REQUEST
  27. @app.route('/deleteHello', methods = ['DELETE'])
  28. def deleteRequestHello():
  29. return "Deleting your hard drive.....haha just kidding! I received a DELETE request!"
  30.  
  31. if __name__ == '__main__':
  32. app.debug = True
  33. app.run(host='0.0.0.0', port=5000)
Add Comment
Please, Sign In to add comment