forked from rDrama/rDrama
1
0
Fork 0
master
Aevann1 2021-10-07 10:43:35 +02:00
parent b9ed87d177
commit c47276a143
5 changed files with 11 additions and 10 deletions

View File

@ -244,7 +244,7 @@ def api_comment(v):
file=request.files["file"]
if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(2)}.gif'
name = f'/images/{int(time.time())}{secrets.token_urlsafe(2)}.gif'
file.save(name)
url = request.host_url[:-1] + process_image(name)
@ -654,7 +654,7 @@ def edit_comment(cid, v):
file=request.files["file"]
if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(2)}.gif'
name = f'/images/{int(time.time())}{secrets.token_urlsafe(2)}.gif'
file.save(name)
url = request.host_url[:-1] + process_image(name)

View File

@ -491,7 +491,7 @@ def thumbnail_thread(pid):
db.close()
return
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(2)}.gif'
name = f'/images/{int(time.time())}{secrets.token_urlsafe(2)}.gif'
with open(name, "wb") as file:
for chunk in image_req.iter_content(1024):
@ -799,7 +799,7 @@ def submit_post(v):
), 403
if file.content_type.startswith('image/'):
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(2)}.gif'
name = f'/images/{int(time.time())}{secrets.token_urlsafe(2)}.gif'
file.save(name)
new_post.url = request.host_url[:-1] + process_image(name)

View File

@ -115,7 +115,7 @@ def settings_profile_post(v):
if request.headers.get("Authorization"): return {"error": f"Image files only"}, 400
else: return render_template("settings_profile.html", v=v, error=f"Image files only."), 400
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(2)}.gif'
name = f'/images/{int(time.time())}{secrets.token_urlsafe(2)}.gif'
file.save(name)
url = request.host_url[:-1] + process_image(name)
@ -517,7 +517,7 @@ def settings_images_profile(v):
file = request.files["profile"]
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(2)}.gif'
name = f'/images/{int(time.time())}{secrets.token_urlsafe(2)}.gif'
file.save(name)
highres = request.host_url[:-1] + process_image(name)
@ -549,7 +549,7 @@ def settings_images_banner(v):
file = request.files["banner"]
name = f'/hostedimages/{int(time.time())}{secrets.token_urlsafe(2)}.gif'
name = f'/images/{int(time.time())}{secrets.token_urlsafe(2)}.gif'
file.save(name)
imageurl = request.host_url[:-1] + process_image(name)

View File

@ -231,12 +231,10 @@ def submit_contact(v):
return render_template("contact.html", v=v, msg="Your message has been sent.")
@app.get('/archives')
@limiter.exempt
def archivesindex():
return redirect("/archives/index.html")
@app.get('/archives/<path:path>')
@limiter.exempt
def archives(path):
resp = make_response(send_from_directory('/archives', path))
if request.path.endswith('.css'): resp.headers.add("Content-Type", "text/css")
@ -252,10 +250,11 @@ def static_service(path):
return resp
@app.get('/images/<path:path>')
@app.get('/hostedimages/<path:path>')
@limiter.exempt
def images(path):
resp = make_response(send_from_directory('/hostedimages', path))
resp = make_response(send_from_directory('/images', path))
resp.headers.remove("Cache-Control")
resp.headers.add("Cache-Control", "public, max-age=2628000")
return resp

View File

@ -6,6 +6,8 @@
{% endblock %}
{% block content %}
<img class="in-comment-image rounded-sm my-2" data-src="https://mediagiphy.com/media/c6Wwc9cT05vMdhyTcM/200w_d.webp" loading="lazy" rel="nofollow noopener noreferrer" data-placeholder-background="red" style="max-height: 100px; max-width: 100%;">
<pre>