diff --git a/main.py b/main.py index 8837fa1..fe61025 100755 --- a/main.py +++ b/main.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # -- coding: utf-8 -- import web @@ -15,7 +15,7 @@ import magic import mimetypes from base64 import urlsafe_b64encode from random import random -from StringIO import StringIO +from io import StringIO sys.path.append(os.path.dirname(__file__)) from config import * @@ -82,8 +82,8 @@ class Pastebin: tempFile.close() # generate the paste's id - pasteid = urlsafe_b64encode(m.digest()[0:9]) - storeName = CONF_DATA_DIR + "/" + pasteid + pasteid = urlsafe_b64encode(m.digest()[0:9]).decode('ascii') + storeName = os.path.join(CONF_DATA_DIR, pasteid) # get the mime type and extension from the data mimeType, ext = self.detect_file_type(tempFileName) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..70aaf4c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +web.py == 0.61 +python-magic ~= 0.4.18 diff --git a/setup_sqlite.sql b/setup_sqlite.sql new file mode 100644 index 0000000..6437a93 --- /dev/null +++ b/setup_sqlite.sql @@ -0,0 +1,6 @@ +CREATE TABLE files ( + hash TEXT NOT NULL PRIMARY KEY, + detected_type TEXT NOT NULL, + create_time INT NOT NULL, + access_time INT NOT NULL, + access_count INT UNSIGNED NOT NULL DEFAULT 0);