fixes
This commit is contained in:
parent
ad0fdeba35
commit
4550143f00
17
main
17
main
|
@ -7,8 +7,10 @@ import json
|
||||||
import secrets
|
import secrets
|
||||||
import datetime
|
import datetime
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
|
from waitress import serve
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
from werkzeug.security import generate_password_hash, check_password_hash
|
from werkzeug.security import generate_password_hash, check_password_hash
|
||||||
|
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||||
from flask import Flask, render_template, request, url_for, flash, redirect, session, make_response, send_from_directory, stream_with_context, Response, request
|
from flask import Flask, render_template, request, url_for, flash, redirect, session, make_response, send_from_directory, stream_with_context, Response, request
|
||||||
from flask_limiter import Limiter
|
from flask_limiter import Limiter
|
||||||
from flask_limiter.util import get_remote_address
|
from flask_limiter.util import get_remote_address
|
||||||
|
@ -28,6 +30,8 @@ app = Flask(__name__)
|
||||||
app.config["SECRET_KEY"] = SECRET_KEY
|
app.config["SECRET_KEY"] = SECRET_KEY
|
||||||
app.config["MAX_CONTENT_LENGTH"] = int(UPLOAD_LIMIT) * 1000 * 1000
|
app.config["MAX_CONTENT_LENGTH"] = int(UPLOAD_LIMIT) * 1000 * 1000
|
||||||
|
|
||||||
|
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1)
|
||||||
|
|
||||||
limiter = Limiter(
|
limiter = Limiter(
|
||||||
get_remote_address,
|
get_remote_address,
|
||||||
app = app,
|
app = app,
|
||||||
|
@ -115,7 +119,6 @@ def get_session(id):
|
||||||
|
|
||||||
ALLOWED_EXTENSIONS = {"png", "apng", "jpg", "jpeg", "gif", "svg", "webp"}
|
ALLOWED_EXTENSIONS = {"png", "apng", "jpg", "jpeg", "gif", "svg", "webp"}
|
||||||
|
|
||||||
|
|
||||||
def allowed_file(filename):
|
def allowed_file(filename):
|
||||||
return '.' in filename and \
|
return '.' in filename and \
|
||||||
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
||||||
|
@ -135,6 +138,7 @@ def main():
|
||||||
else:
|
else:
|
||||||
return render_template("main.html", posts=posts)
|
return render_template("main.html", posts=posts)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/@<pageusername>", methods=("GET", "POST"))
|
@app.route("/@<pageusername>", methods=("GET", "POST"))
|
||||||
def user(pageusername):
|
def user(pageusername):
|
||||||
usersession = request.cookies.get("session_DO_NOT_SHARE")
|
usersession = request.cookies.get("session_DO_NOT_SHARE")
|
||||||
|
@ -152,6 +156,16 @@ def user(pageusername):
|
||||||
else:
|
else:
|
||||||
return """<img src="https://http.cat/images/404.jpg">""", 404
|
return """<img src="https://http.cat/images/404.jpg">""", 404
|
||||||
|
|
||||||
|
@app.route("/api/page/<userid>", methods=("GET", "POST"))
|
||||||
|
def apipageuser(userid):
|
||||||
|
pageuser = get_user(userid)
|
||||||
|
addhtml = """<head><meta http-equiv="Content-Security-Policy" default-src='none'; content="img-src cdn.discordapp.com media.tenor.com; style-src: 'self'" /></head>"""
|
||||||
|
|
||||||
|
if not pageuser == "error":
|
||||||
|
return addhtml + pageuser["htmldescription"]
|
||||||
|
else:
|
||||||
|
return """<img src="https://http.cat/images/404.jpg">""", 404
|
||||||
|
|
||||||
@app.route("/@<pageusername>/edit", methods=("GET", "POST"))
|
@app.route("/@<pageusername>/edit", methods=("GET", "POST"))
|
||||||
def edituser(pageusername):
|
def edituser(pageusername):
|
||||||
usersession = request.cookies.get("session_DO_NOT_SHARE")
|
usersession = request.cookies.get("session_DO_NOT_SHARE")
|
||||||
|
@ -582,7 +596,6 @@ def page_not_found(e):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from waitress import serve
|
|
||||||
print("[INFO] Server started")
|
print("[INFO] Server started")
|
||||||
serve(app, host=HOST, port=PORT)
|
serve(app, host=HOST, port=PORT)
|
||||||
#app.run(host=HOST, port=PORT, debug=True)
|
#app.run(host=HOST, port=PORT, debug=True)
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
{% if userdata %}
|
{% if userdata %}
|
||||||
{% if pageuser.id == userdata.id %}
|
{% if pageuser.id == userdata.id %}
|
||||||
<h2>edit mode</h2>
|
<h2>edit mode</h2>
|
||||||
|
<p>remote content from media.tenor.com and cdn.discordapp.com is allowed</p>
|
||||||
<form class="editThing" method="post" enctype="multipart/form-data">
|
<form class="editThing" method="post" enctype="multipart/form-data">
|
||||||
<textarea class="htmlBox" name="code" type="text" placeholder="<p>Hello World!</p>">{{ userdata.htmldescription }}</textarea>
|
<textarea class="htmlBox" name="code" type="text" placeholder="<p>Hello World!</p>">{{ userdata.htmldescription }}</textarea>
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
|
@ -7,9 +7,7 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||||
<link rel="stylesheet" type="text/css" href="/static/css/style.css" />
|
<link rel="stylesheet" type="text/css" href="/static/css/style.css" />
|
||||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' fonts.gstatic.com fonts.googleapis.com" />
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="navbar">
|
<div class="navbar">
|
||||||
<h1>burgercat</h1>
|
<h1>burgercat</h1>
|
||||||
|
@ -39,7 +37,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<iframe class="profileIFrame" sandbox="" srcdoc="{{ pageuser.htmldescription }}"></iframe>
|
<iframe src="/api/page/{{ pageuser.id }}" class="profileIFrame" sandbox=""></iframe>
|
||||||
</div>
|
</div>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
|
Reference in New Issue