Make compatible with current Python versions

This commit is contained in:
Kumi 2022-05-02 09:44:40 +02:00
parent edef07a592
commit a6fecaae9f
Signed by: kumi
GPG key ID: 5D1CE6AF1805ECA2
3 changed files with 8 additions and 5 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@ __pycache__
*.swp
*.err
*.png
venv/

View file

@ -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()

View file

@ -1,4 +1,3 @@
import cgi
from server.connections import Request, Response
import mimetypes
import handler