fsdfsd
This commit is contained in:
parent
6151ae1580
commit
cc966888e6
5 changed files with 11 additions and 10 deletions
|
@ -244,7 +244,7 @@ def api_comment(v):
|
||||||
file=request.files["file"]
|
file=request.files["file"]
|
||||||
if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400
|
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)
|
file.save(name)
|
||||||
url = request.host_url[:-1] + process_image(name)
|
url = request.host_url[:-1] + process_image(name)
|
||||||
|
|
||||||
|
@ -654,7 +654,7 @@ def edit_comment(cid, v):
|
||||||
file=request.files["file"]
|
file=request.files["file"]
|
||||||
if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400
|
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)
|
file.save(name)
|
||||||
url = request.host_url[:-1] + process_image(name)
|
url = request.host_url[:-1] + process_image(name)
|
||||||
|
|
||||||
|
|
|
@ -491,7 +491,7 @@ def thumbnail_thread(pid):
|
||||||
db.close()
|
db.close()
|
||||||
return
|
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:
|
with open(name, "wb") as file:
|
||||||
for chunk in image_req.iter_content(1024):
|
for chunk in image_req.iter_content(1024):
|
||||||
|
@ -799,7 +799,7 @@ def submit_post(v):
|
||||||
), 403
|
), 403
|
||||||
|
|
||||||
if file.content_type.startswith('image/'):
|
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)
|
file.save(name)
|
||||||
new_post.url = request.host_url[:-1] + process_image(name)
|
new_post.url = request.host_url[:-1] + process_image(name)
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ def settings_profile_post(v):
|
||||||
if request.headers.get("Authorization"): return {"error": f"Image files only"}, 400
|
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
|
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)
|
file.save(name)
|
||||||
url = request.host_url[:-1] + process_image(name)
|
url = request.host_url[:-1] + process_image(name)
|
||||||
|
|
||||||
|
@ -517,7 +517,7 @@ def settings_images_profile(v):
|
||||||
|
|
||||||
file = request.files["profile"]
|
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)
|
file.save(name)
|
||||||
highres = request.host_url[:-1] + process_image(name)
|
highres = request.host_url[:-1] + process_image(name)
|
||||||
|
|
||||||
|
@ -549,7 +549,7 @@ def settings_images_banner(v):
|
||||||
|
|
||||||
file = request.files["banner"]
|
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)
|
file.save(name)
|
||||||
imageurl = request.host_url[:-1] + process_image(name)
|
imageurl = request.host_url[:-1] + process_image(name)
|
||||||
|
|
||||||
|
|
|
@ -231,12 +231,10 @@ def submit_contact(v):
|
||||||
return render_template("contact.html", v=v, msg="Your message has been sent.")
|
return render_template("contact.html", v=v, msg="Your message has been sent.")
|
||||||
|
|
||||||
@app.get('/archives')
|
@app.get('/archives')
|
||||||
@limiter.exempt
|
|
||||||
def archivesindex():
|
def archivesindex():
|
||||||
return redirect("/archives/index.html")
|
return redirect("/archives/index.html")
|
||||||
|
|
||||||
@app.get('/archives/<path:path>')
|
@app.get('/archives/<path:path>')
|
||||||
@limiter.exempt
|
|
||||||
def archives(path):
|
def archives(path):
|
||||||
resp = make_response(send_from_directory('/archives', path))
|
resp = make_response(send_from_directory('/archives', path))
|
||||||
if request.path.endswith('.css'): resp.headers.add("Content-Type", "text/css")
|
if request.path.endswith('.css'): resp.headers.add("Content-Type", "text/css")
|
||||||
|
@ -252,10 +250,11 @@ def static_service(path):
|
||||||
|
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
@app.get('/images/<path:path>')
|
||||||
@app.get('/hostedimages/<path:path>')
|
@app.get('/hostedimages/<path:path>')
|
||||||
@limiter.exempt
|
@limiter.exempt
|
||||||
def images(path):
|
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.remove("Cache-Control")
|
||||||
resp.headers.add("Cache-Control", "public, max-age=2628000")
|
resp.headers.add("Cache-Control", "public, max-age=2628000")
|
||||||
return resp
|
return resp
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% 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>
|
<pre>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue