|
@@ -21,11 +21,7 @@ from .save import save_upload
|
|
|
from .qr import get_qr_code
|
|
|
from json import dumps, load
|
|
|
|
|
|
-app = default_app()
|
|
|
-from bottle.ext import sqlite
|
|
|
-from sqlite3 import Row
|
|
|
-plugin = sqlite.Plugin(dbfile='/tmp/test.db')
|
|
|
-app.install(plugin)
|
|
|
+from sqlite3 import connect, Row
|
|
|
|
|
|
SCHEME = "https://"
|
|
|
HOST = ""
|
|
@@ -92,24 +88,25 @@ def clip(route):
|
|
|
def get_clip(route, filename):
|
|
|
return redirect(f'/{route}.sql?hash={filename}&go=true')
|
|
|
|
|
|
-@app.route(f'/upload/<hash:re:{B32REGEX}{{1,5}}>', method='GET')
|
|
|
+@route(f'/upload/<hash:re:{B32REGEX}{{1,5}}>', method='GET')
|
|
|
def get_upload(hash, db=None):
|
|
|
hash = hash and normalize_base32(hash)
|
|
|
- ret: Row = db.execute(f"""
|
|
|
+ con = connect('util.db')
|
|
|
+ try:
|
|
|
+ ret: Row = con.cursor().execute(f"""
|
|
|
SELECT content
|
|
|
FROM clip
|
|
|
WHERE hash = '{hash}'
|
|
|
LIMIT 1;
|
|
|
-""").fetchall()[0]
|
|
|
-
|
|
|
-
|
|
|
+""").fetchall()[0][0].encode('utf-8')
|
|
|
+ finally:
|
|
|
+ con.close()
|
|
|
|
|
|
download = True
|
|
|
mimetype = True
|
|
|
if request.params.download == "false":
|
|
|
download = False
|
|
|
mimetype = request.params.mimetype or None
|
|
|
- response.body = ret
|
|
|
headers = {}
|
|
|
headers['Content-Length'] = len(ret)
|
|
|
fname = 'noddy'
|
|
@@ -125,7 +122,7 @@ LIMIT 1;
|
|
|
|
|
|
|
|
|
|
|
|
- return HTTPResponse(ret[0].encode('utf8'), **headers)
|
|
|
+ return HTTPResponse(ret, **headers)
|
|
|
|
|
|
@route('/upload', method=['GET', 'POST'])
|
|
|
def upload():
|