From a6fecaae9f98cc0f3e0f9b94019bb3d78d492b18 Mon Sep 17 00:00:00 2001 From: Kumi Date: Mon, 2 May 2022 09:44:40 +0200 Subject: [PATCH] Make compatible with current Python versions --- .gitignore | 3 ++- server/connections.py | 9 ++++++--- server/daemon.py | 1 - 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 8af90e1..fcc7d7b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ __pycache__ *.swp *.err -*.png \ No newline at end of file +*.png +venv/ \ No newline at end of file diff --git a/server/connections.py b/server/connections.py index 64581cd..575d0eb 100644 --- a/server/connections.py +++ b/server/connections.py @@ -1,4 +1,7 @@ -import cgi +try: + from urllib.parse import parse_qs +except: + from cgi import parse_qs class IllegalMethodException(BaseException): pass @@ -13,9 +16,9 @@ class Request: def fromEnv(self, env): if env["REQUEST_METHOD"] == "POST": - self.args = cgi.parse_qs(env['wsgi.input'].readline().decode(), True) + self.args = parse_qs(env['wsgi.input'].readline().decode(), True) elif env["REQUEST_METHOD"] == "GET": - self.args = cgi.parse_qs(env['QUERY_STRING'], True) + self.args = parse_qs(env['QUERY_STRING'], True) else: raise IllegalMethodException() diff --git a/server/daemon.py b/server/daemon.py index 492d72d..5aed1cd 100644 --- a/server/daemon.py +++ b/server/daemon.py @@ -1,4 +1,3 @@ -import cgi from server.connections import Request, Response import mimetypes import handler