Tests about a simple python3 fastcgi runner using libfcgi and the Python-C API.
python
c
wsgi
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

foo_pep333.py 853B

1234567891011121314151617181920212223242526272829
  1. import sys
  2. import os
  3. import time
  4. import random
  5. from pprint import pformat
  6. random.seed()
  7. def entrypoint(env, start_response):
  8. write_body = start_response("200 OK", [('Content-type', 'text/plain')])
  9. if not "wsgi.input" in env:
  10. raise ValueError("Given environ does not contain any 'wsgi.input' key !")
  11. data_in = env["wsgi.input"]
  12. #for l in data_in:
  13. # write_body("POST data line : %s" % repr(l))
  14. #data = data_in.readlines()
  15. while True:
  16. data = data_in.read(98)
  17. write_body(("POST data : %s\n====\n" % repr(data)).encode())
  18. if not data:
  19. break
  20. write_body(("Environ data :\n'%s'\n====\n" % pformat(env)).encode())
  21. print("Hello world !")
  22. print("False error :D", file=sys.stderr)
  23. 5/0
  24. time.sleep(random.randint(0,15)/1000)
  25. #time.sleep(random.randint(0,15)/100)
  26. #if random.randint(0,100) > 98:
  27. # time.sleep(3)
  28. return [b'Hello world !\n']