summaryrefslogtreecommitdiff
path: root/wsgitools/applications.py
diff options
context:
space:
mode:
Diffstat (limited to 'wsgitools/applications.py')
-rw-r--r--wsgitools/applications.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/wsgitools/applications.py b/wsgitools/applications.py
index df304db..9894cf8 100644
--- a/wsgitools/applications.py
+++ b/wsgitools/applications.py
@@ -2,13 +2,8 @@ import os.path
__all__ = []
-try:
- basestring
-except NameError:
- basestring = str
-
__all__.append("StaticContent")
-class StaticContent(object):
+class StaticContent:
"""
This wsgi application provides static content on whatever request it
receives with method GET or HEAD (content stripped). If not present, a
@@ -60,7 +55,7 @@ class StaticContent(object):
return self.content
__all__.append("StaticFile")
-class StaticFile(object):
+class StaticFile:
"""
This wsgi application provides the content of a static file on whatever
request it receives with method GET or HEAD (content stripped). If not
@@ -94,7 +89,7 @@ class StaticFile(object):
if not data:
break
yield data
- if isinstance(self.filelike, basestring):
+ if isinstance(self.filelike, str):
stream.close()
def __call__(self, environ, start_response):
@@ -110,7 +105,7 @@ class StaticFile(object):
stream = None
size = -1
try:
- if isinstance(self.filelike, basestring):
+ if isinstance(self.filelike, str):
# raises IOError
stream = open(self.filelike, "rb")
size = os.path.getsize(self.filelike)
@@ -133,16 +128,16 @@ class StaticFile(object):
start_response(self.status, headers)
if environ["REQUEST_METHOD"].upper() == "HEAD":
- if isinstance(self.filelike, basestring):
+ if isinstance(self.filelike, str):
stream.close()
return []
- if isinstance(self.filelike, basestring) and 'wsgi.file_wrapper' in environ:
+ if isinstance(self.filelike, str) and 'wsgi.file_wrapper' in environ:
return environ['wsgi.file_wrapper'](stream, self.blocksize)
if 0 <= size <= self.blocksize:
data = stream.read(size)
- if isinstance(self.filelike, basestring):
+ if isinstance(self.filelike, str):
stream.close()
return [data]
return self._serve_in_chunks(stream)