Port to Python 3
This commit is contained in:
parent
37f600d9c2
commit
f69c1bcb8c
8
main.py
8
main.py
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# -- coding: utf-8 --
|
# -- coding: utf-8 --
|
||||||
|
|
||||||
import web
|
import web
|
||||||
|
@ -15,7 +15,7 @@ import magic
|
||||||
import mimetypes
|
import mimetypes
|
||||||
from base64 import urlsafe_b64encode
|
from base64 import urlsafe_b64encode
|
||||||
from random import random
|
from random import random
|
||||||
from StringIO import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
sys.path.append(os.path.dirname(__file__))
|
sys.path.append(os.path.dirname(__file__))
|
||||||
from config import *
|
from config import *
|
||||||
|
@ -82,8 +82,8 @@ class Pastebin:
|
||||||
tempFile.close()
|
tempFile.close()
|
||||||
|
|
||||||
# generate the paste's id
|
# generate the paste's id
|
||||||
pasteid = urlsafe_b64encode(m.digest()[0:9])
|
pasteid = urlsafe_b64encode(m.digest()[0:9]).decode('ascii')
|
||||||
storeName = CONF_DATA_DIR + "/" + pasteid
|
storeName = os.path.join(CONF_DATA_DIR, pasteid)
|
||||||
|
|
||||||
# get the mime type and extension from the data
|
# get the mime type and extension from the data
|
||||||
mimeType, ext = self.detect_file_type(tempFileName)
|
mimeType, ext = self.detect_file_type(tempFileName)
|
||||||
|
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
web.py == 0.61
|
||||||
|
python-magic ~= 0.4.18
|
6
setup_sqlite.sql
Normal file
6
setup_sqlite.sql
Normal file
|
@ -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);
|
Loading…
Reference in a new issue