SDF
parent
e4b1dde431
commit
022e300d2f
|
@ -19,7 +19,7 @@ from json import loads
|
|||
|
||||
f = 'files/templates/sidebar_' + environ.get("SITE_NAME").strip() + '.html'
|
||||
if not path.exists(f):
|
||||
with open(f, 'w'): pass
|
||||
with open(f, 'w', encoding="utf-8"): pass
|
||||
|
||||
app = Flask(__name__, template_folder='templates')
|
||||
app.url_map.strict_slashes = False
|
||||
|
|
|
@ -41,7 +41,7 @@ def get_hand_value(hand):
|
|||
|
||||
|
||||
def format_cards(hand):
|
||||
return map(lambda x: "".join(x), hand)
|
||||
return map("".join(x), hand)
|
||||
|
||||
|
||||
def format_all(player_hand, dealer_hand, deck, status, wager):
|
||||
|
|
|
@ -159,7 +159,7 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
|
|||
tag["data-src"] = tag["src"]
|
||||
tag["src"] = "/static/assets/images/loading.webp"
|
||||
tag['alt'] = f'![]({tag["data-src"]})'
|
||||
tag["onclick"] = f"expandDesktopImage(this.src);"
|
||||
tag["onclick"] = "expandDesktopImage(this.src);"
|
||||
tag["data-bs-toggle"] = "modal"
|
||||
tag["data-bs-target"] = "#expandImageModal"
|
||||
|
||||
|
|
|
@ -314,7 +314,7 @@ def monthly(v):
|
|||
def get_sidebar(v):
|
||||
|
||||
try:
|
||||
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r') as f: sidebar = f.read()
|
||||
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r', encoding="utf-8") as f: sidebar = f.read()
|
||||
except:
|
||||
sidebar = None
|
||||
|
||||
|
@ -328,9 +328,9 @@ def post_sidebar(v):
|
|||
|
||||
text = request.values.get('sidebar', '').strip()
|
||||
|
||||
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'w+') as f: f.write(text)
|
||||
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'w+', encoding="utf-8") as f: f.write(text)
|
||||
|
||||
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r') as f: sidebar = f.read()
|
||||
with open(f'files/templates/sidebar_{SITE_NAME}.html', 'r', encoding="utf-8") as f: sidebar = f.read()
|
||||
|
||||
ma = ModAction(
|
||||
kind="change_sidebar",
|
||||
|
|
|
@ -165,7 +165,7 @@ def api_comment(v):
|
|||
body = request.values.get("body", "").strip()[:10000]
|
||||
|
||||
if v.admin_level == 3 and parent_post.id == 37749:
|
||||
with open(f"snappy_{SITE_NAME}.txt", "a") as f:
|
||||
with open(f"snappy_{SITE_NAME}.txt", "a", encoding="utf-8") as f:
|
||||
f.write('\n{[para]}\n' + body)
|
||||
|
||||
if v.marseyawarded and parent_post.id not in (37696,37697,37749,37833,37838):
|
||||
|
|
|
@ -24,7 +24,7 @@ marseys = tuple(f':#{x[0]}:' for x in db.query(Marsey.name).all())
|
|||
db.close()
|
||||
|
||||
if path.exists(f'snappy_{SITE_NAME}.txt'):
|
||||
with open(f'snappy_{SITE_NAME}.txt', "r") as f:
|
||||
with open(f'snappy_{SITE_NAME}.txt', "r", encoding="utf-8") as f:
|
||||
if SITE == 'pcmemes.net': snappyquotes = tuple(f.read().split("{[para]}"))
|
||||
else: snappyquotes = tuple(f.read().split("{[para]}")) + marseys
|
||||
else: snappyquotes = marseys
|
||||
|
|
|
@ -66,7 +66,7 @@ def searchposts(v):
|
|||
if 'author' in criteria:
|
||||
posts = posts.filter(Submission.ghost == None)
|
||||
author = get_user(criteria['author'])
|
||||
if not author: return {"error": f"User not found"}
|
||||
if not author: return {"error": "User not found"}
|
||||
if author.is_private and author.id != v.id and v.admin_level < 2 and not v.eye:
|
||||
if request.headers.get("Authorization"):
|
||||
return {"error": f"@{author.username}'s profile is private; You can't use the 'author' syntax on them"}
|
||||
|
@ -213,7 +213,7 @@ def searchcomments(v):
|
|||
if 'author' in criteria:
|
||||
comments = comments.filter(Comment.ghost == None)
|
||||
author = get_user(criteria['author'])
|
||||
if not author: return {"error": f"User not found"}
|
||||
if not author: return {"error": "User not found"}
|
||||
if author.is_private and author.id != v.id and v.admin_level < 2 and not v.eye:
|
||||
if request.headers.get("Authorization"):
|
||||
return {"error": f"@{author.username}'s profile is private; You can't use the 'author' syntax on them"}
|
||||
|
|
|
@ -384,7 +384,7 @@ def formatting(v):
|
|||
|
||||
@app.get("/service-worker.js")
|
||||
def serviceworker():
|
||||
with open("files/assets/js/service-worker.js", "r") as f: return Response(f.read(), mimetype='application/javascript')
|
||||
with open("files/assets/js/service-worker.js", "r", encoding="utf-8") as f: return Response(f.read(), mimetype='application/javascript')
|
||||
|
||||
@app.get("/settings/security")
|
||||
@auth_required
|
||||
|
|
|
@ -256,9 +256,9 @@ def transfer_coins(v, username):
|
|||
amount = request.values.get("amount", "").strip()
|
||||
amount = int(amount) if amount.isdigit() else None
|
||||
|
||||
if amount is None or amount <= 0: return {"error": f"Invalid amount of coins."}, 400
|
||||
if v.coins < amount: return {"error": f"You don't have enough coins."}, 400
|
||||
if amount < 100: return {"error": f"You have to gift at least 100 coins."}, 400
|
||||
if amount is None or amount <= 0: return {"error": "Invalid amount of coins."}, 400
|
||||
if v.coins < amount: return {"error": "You don't have enough coins."}, 400
|
||||
if amount < 100: return {"error": "You have to gift at least 100 coins."}, 400
|
||||
|
||||
if not v.patron and not receiver.patron and not v.alts_patron and not receiver.alts_patron: tax = math.ceil(amount*0.03)
|
||||
else: tax = 0
|
||||
|
@ -275,7 +275,7 @@ def transfer_coins(v, username):
|
|||
g.db.commit()
|
||||
return {"message": f"{amount-tax} coins transferred!"}, 200
|
||||
|
||||
return {"message": f"You can't transfer coins to yourself!"}, 400
|
||||
return {"message": "You can't transfer coins to yourself!"}, 400
|
||||
|
||||
|
||||
@app.post("/@<username>/transfer_bux")
|
||||
|
|
Loading…
Reference in New Issue