Я написал простой веб-сервер с python3 и модулями WSGI:
#!/usr/bin/python3
from wsgiref.simple_server import make_server
port = 80
count = 0
def hello_app(environ, start_response):
global count
status = '200 OK' # HTTP Status
headers = [('Content-type', 'text/plain')] # HTTP Headers
start_response(status, headers)
response = "hello number {}".format(count)
count += 1
return( [response.encode()] )
httpd = make_server('', port, hello_app)
print("Serving HTTP on port {}...".format(port))
# Respond to requests until process is killed
httpd.serve_forever()
И он работает нормально, но каждый раз, когда я делаю запрос от посредника, счетчик увеличивается на 2, а не одним. Если я закомментирую «count + = 1», он просто останется равным нулю. Почему?