Guest User

Untitled

a guest
Feb 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. from wsgiref.simple_server import make_server
  2. import random
  3.  
  4.  
  5. def application(env, start_response):
  6. """
  7. A basic WSGI application
  8. """
  9.  
  10. if random.random() < 0.5:
  11. status = "200 OK"
  12. else:
  13. status = "502 Bad Gateway"
  14.  
  15. headers = [
  16. ('Content-Type', 'application/json'),
  17. ('X-WP-TotalPages', '0'),
  18. ('X-WP-Total', '0'),
  19. ]
  20.  
  21. start_response(status, headers)
  22.  
  23. return ["[]".encode('utf-8')]
  24.  
  25.  
  26. if __name__ == "__main__":
  27. make_server('', 80, application).serve_forever()
Add Comment
Please, Sign In to add comment