Tests about a simple python3 fastcgi runner using libfcgi and the Python-C API.
python
c
wsgi
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

foo_pep333.py 626B

1234567891011121314151617181920
  1. import sys
  2. import os
  3. import time
  4. from pprint import pformat
  5. def entrypoint(env, start_response):
  6. write_body = start_response("200 OK", [('Content-type', 'text/plain')])
  7. if not "wsgi.input" in env:
  8. raise ValueError("Given environ does not contain any 'wsgi.input' key !")
  9. data_in = env["wsgi.input"]
  10. #for l in data_in:
  11. # write_body("POST data line : %s" % repr(l))
  12. #data = data_in.readlines()
  13. while True:
  14. data = data_in.read(98)
  15. write_body(("POST data : %s\n====\n" % repr(data)).encode())
  16. if not data:
  17. break
  18. write_body(("Environ data :\n'%s'\n====\n" % pformat(env)).encode())
  19. return [b'Hello world !\n']