Python CGIHTTPServer Default Directories

前端 未结 3 969
时光取名叫无心
时光取名叫无心 2021-01-19 15:58

I\'ve got the following minimal code for a CGI-handling HTTP server, derived from several examples on the inner-tubes:

#!/usr/bin/env python

import BaseHTTP         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-19 16:48

    My suspicions were correct. The examples from which this code is derived showed the wrong way to set the default directory to be the same directory in which the server script resides. To set the default directory in this way, use:

    handler.cgi_directories = ["/"]
    

    Caution: This opens up potentially huge security holes if you're not behind any kind of a firewall. This is only an instructive example. Use only with extreme care.

提交回复
热议问题