Reading a client's header from Python CGI script?

前端 未结 4 2142
我在风中等你
我在风中等你 2021-02-12 20:21

I\'m writing a very simple web service, written in Python and run as CGI on an Apache server.

According to Python docs (somewhere... I forgot where), I can use sys.stdin

4条回答
  •  无人共我
    2021-02-12 20:24

    These are given to the CGI script through the environment:

    import os
    user_agent = os.environ["HTTP_USER_AGENT"]
    ip = os.environ["REMOTE_ADDR"]
    

提交回复
热议问题