Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
RDCH106 committed Feb 16, 2017
1 parent 48e3eca commit 1dc336f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions simple_file_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
import sys
import base64
import settings

Expand All @@ -46,7 +45,6 @@ def incr_counter(self, path):
res += 1
self.cursor.execute('REPLACE INTO counter(fullpath, count) VALUES(?, ?)', (path, res))
self.conn.commit()
pass

def read_counter(self, path):
""" Read the counter that counts how many times a path is visited """
Expand Down Expand Up @@ -114,11 +112,13 @@ def do_GET(self):
f.close()

def do_POST(self):
"""Serve a POST request."""

if not self.try_authenticate():
return
print 'authenticated'

"""Serve a POST request."""

r, info = self.deal_post_data()
print r, info, "by: ", self.client_address
f = StringIO()
Expand Down Expand Up @@ -299,14 +299,16 @@ def list_directory(self, dir_path):
self.end_headers()
return f

def url_path_to_file_path(self, url_path):
@staticmethod
def url_path_to_file_path(url_path):
# abandon query parameters
url_path = url_path.split('?',1)[0]
url_path = url_path.split('#',1)[0]
url_path = posixpath.normpath(urllib.unquote(url_path))
return settings.base_url + url_path

def copyfile(self, source, outputfile):
@staticmethod
def copyfile(source, outputfile):
"""Copy all data between two file objects.
The SOURCE argument is a file object open for reading
Expand Down

0 comments on commit 1dc336f

Please sign in to comment.