|
@@ -132,7 +132,7 @@ def clip():
|
|
if request.params.copy != 'true':
|
|
if request.params.copy != 'true':
|
|
_b32 = save(content)
|
|
_b32 = save(content)
|
|
return redirect(f'/clip?hash={_b32}')
|
|
return redirect(f'/clip?hash={_b32}')
|
|
-
|
|
|
|
|
|
+
|
|
response.content_type = 'text/html; charset=utf-8'
|
|
response.content_type = 'text/html; charset=utf-8'
|
|
form = template(
|
|
form = template(
|
|
'clip-form',
|
|
'clip-form',
|
|
@@ -170,7 +170,7 @@ def upload():
|
|
_hash = request.params.hash
|
|
_hash = request.params.hash
|
|
if _hash:
|
|
if _hash:
|
|
_hash = normalize_base32(_hash)
|
|
_hash = normalize_base32(_hash)
|
|
-
|
|
|
|
|
|
+
|
|
link = f'{LOCATION}/upload/{_hash}' if _hash else f'{LOCATION}/upload'
|
|
link = f'{LOCATION}/upload/{_hash}' if _hash else f'{LOCATION}/upload'
|
|
response.content_type = 'text/html; charset=utf-8'
|
|
response.content_type = 'text/html; charset=utf-8'
|
|
form = template('file-form', action='/upload', method='post')
|
|
form = template('file-form', action='/upload', method='post')
|
|
@@ -179,7 +179,7 @@ def upload():
|
|
if request.method == 'POST':
|
|
if request.method == 'POST':
|
|
if 'paste' not in request.files:
|
|
if 'paste' not in request.files:
|
|
return abort(400, "Parameter 'paste' must be specified")
|
|
return abort(400, "Parameter 'paste' must be specified")
|
|
-
|
|
|
|
|
|
+
|
|
upload = request.files['paste']
|
|
upload = request.files['paste']
|
|
if isinstance(upload.file, BytesIO):
|
|
if isinstance(upload.file, BytesIO):
|
|
if len(upload.file.read()) == 0:
|
|
if len(upload.file.read()) == 0:
|
|
@@ -205,11 +205,11 @@ def goto():
|
|
content = validate(_hash).decode('utf-8')
|
|
content = validate(_hash).decode('utf-8')
|
|
else:
|
|
else:
|
|
content = None
|
|
content = None
|
|
-
|
|
|
|
|
|
+
|
|
if content and request.params.go == 'true':
|
|
if content and request.params.go == 'true':
|
|
target = validate_url(content)
|
|
target = validate_url(content)
|
|
return redirect(target)
|
|
return redirect(target)
|
|
-
|
|
|
|
|
|
+
|
|
link = f'{LOCATION}/goto/{_hash}' if content else f'{LOCATION}/goto'
|
|
link = f'{LOCATION}/goto/{_hash}' if content else f'{LOCATION}/goto'
|
|
disabled = True if content else False
|
|
disabled = True if content else False
|
|
response.content_type = 'text/html; charset=utf-8'
|
|
response.content_type = 'text/html; charset=utf-8'
|
|
@@ -222,10 +222,14 @@ def goto():
|
|
)
|
|
)
|
|
preview = dict()
|
|
preview = dict()
|
|
if content:
|
|
if content:
|
|
- page = link_preview(link, parser="lxml")
|
|
|
|
- preview['title'] = page.title
|
|
|
|
- preview['img'] = page.absolute_image
|
|
|
|
- preview['domain'] = page.site_name
|
|
|
|
|
|
+ try:
|
|
|
|
+ page = link_preview(link, parser="lxml")
|
|
|
|
+ preview['title'] = page.title
|
|
|
|
+ preview['img'] = page.absolute_image
|
|
|
|
+ preview['domain'] = page.site_name
|
|
|
|
+ preview['link'] = content
|
|
|
|
+ except:
|
|
|
|
+ pass
|
|
|
|
|
|
return template(
|
|
return template(
|
|
'goto',
|
|
'goto',
|