feat: Add some better checks
All checks were successful
Build Docker / BuildImage (push) Successful in 50s
All checks were successful
Build Docker / BuildImage (push) Successful in 50s
This commit is contained in:
2
blog.py
2
blog.py
@@ -48,7 +48,7 @@ def fix_numbered_lists(html):
|
|||||||
# Find the <p> tag containing numbered steps
|
# Find the <p> tag containing numbered steps
|
||||||
paragraphs = soup.find_all('p')
|
paragraphs = soup.find_all('p')
|
||||||
for p in paragraphs:
|
for p in paragraphs:
|
||||||
content = p.decode_contents()
|
content = p.decode_contents() # type: ignore
|
||||||
|
|
||||||
# Check for likely numbered step structure
|
# Check for likely numbered step structure
|
||||||
if re.search(r'1\.\s', content):
|
if re.search(r'1\.\s', content):
|
||||||
|
|||||||
19
mail.py
19
mail.py
@@ -22,7 +22,11 @@ import os
|
|||||||
# }'
|
# }'
|
||||||
|
|
||||||
def validateSender(email):
|
def validateSender(email):
|
||||||
domains = os.getenv("EMAIL_DOMAINS").split(",")
|
domains = os.getenv("EMAIL_DOMAINS")
|
||||||
|
if not domains:
|
||||||
|
return False
|
||||||
|
|
||||||
|
domains = domains.split(",")
|
||||||
for domain in domains:
|
for domain in domains:
|
||||||
if re.match(r".+@" + domain, email):
|
if re.match(r".+@" + domain, email):
|
||||||
return True
|
return True
|
||||||
@@ -84,8 +88,17 @@ def sendEmail(data):
|
|||||||
|
|
||||||
# Sending the email
|
# Sending the email
|
||||||
try:
|
try:
|
||||||
with smtplib.SMTP_SSL(os.getenv("EMAIL_SMTP"), 465) as server:
|
host = os.getenv("EMAIL_SMTP")
|
||||||
server.login(os.getenv("EMAIL_USER"), os.getenv("EMAIL_PASS"))
|
user = os.getenv("EMAIL_USER")
|
||||||
|
password = os.getenv("EMAIL_PASS")
|
||||||
|
if host is None or user is None or password is None:
|
||||||
|
return jsonify({
|
||||||
|
"status": 500,
|
||||||
|
"error": "Email server not configured"
|
||||||
|
})
|
||||||
|
|
||||||
|
with smtplib.SMTP_SSL(host, 465) as server:
|
||||||
|
server.login(user, password)
|
||||||
server.sendmail(fromEmail, to, msg.as_string())
|
server.sendmail(fromEmail, to, msg.as_string())
|
||||||
print("Email sent successfully.")
|
print("Email sent successfully.")
|
||||||
return jsonify({
|
return jsonify({
|
||||||
|
|||||||
4
main.py
4
main.py
@@ -17,8 +17,8 @@ class GunicornApp(BaseApplication):
|
|||||||
|
|
||||||
def load_config(self):
|
def load_config(self):
|
||||||
for key, value in self.options.items():
|
for key, value in self.options.items():
|
||||||
if key in self.cfg.settings and value is not None:
|
if key in self.cfg.settings and value is not None: # type: ignore
|
||||||
self.cfg.set(key.lower(), value)
|
self.cfg.set(key.lower(), value) # type: ignore
|
||||||
|
|
||||||
def load(self):
|
def load(self):
|
||||||
return self.application
|
return self.application
|
||||||
|
|||||||
91
server.py
91
server.py
@@ -16,6 +16,7 @@ import requests
|
|||||||
from cloudflare import Cloudflare
|
from cloudflare import Cloudflare
|
||||||
import datetime
|
import datetime
|
||||||
import qrcode
|
import qrcode
|
||||||
|
from qrcode.constants import ERROR_CORRECT_L, ERROR_CORRECT_H
|
||||||
import re
|
import re
|
||||||
import binascii
|
import binascii
|
||||||
import base64
|
import base64
|
||||||
@@ -134,6 +135,7 @@ def send_report(path):
|
|||||||
|
|
||||||
return render_template("404.html"), 404
|
return render_template("404.html"), 404
|
||||||
|
|
||||||
|
|
||||||
def getClientIP(request):
|
def getClientIP(request):
|
||||||
x_forwarded_for = request.headers.get("X-Forwarded-For")
|
x_forwarded_for = request.headers.get("X-Forwarded-For")
|
||||||
if x_forwarded_for:
|
if x_forwarded_for:
|
||||||
@@ -142,6 +144,7 @@ def getClientIP(request):
|
|||||||
ip = request.remote_addr
|
ip = request.remote_addr
|
||||||
return ip
|
return ip
|
||||||
|
|
||||||
|
|
||||||
def getVersion():
|
def getVersion():
|
||||||
# if .git exists, get the latest commit hash
|
# if .git exists, get the latest commit hash
|
||||||
if os.path.isdir(".git"):
|
if os.path.isdir(".git"):
|
||||||
@@ -198,6 +201,7 @@ def faviconPNG():
|
|||||||
def faviconSVG():
|
def faviconSVG():
|
||||||
return send_from_directory("templates/assets/img/favicon", "favicon.svg")
|
return send_from_directory("templates/assets/img/favicon", "favicon.svg")
|
||||||
|
|
||||||
|
|
||||||
@app.route("/favicon.ico")
|
@app.route("/favicon.ico")
|
||||||
def faviconICO():
|
def faviconICO():
|
||||||
return send_from_directory("templates/assets/img/favicon", "favicon.ico")
|
return send_from_directory("templates/assets/img/favicon", "favicon.ico")
|
||||||
@@ -284,6 +288,7 @@ def manifest():
|
|||||||
manifest["scope"] = url
|
manifest["scope"] = url
|
||||||
return jsonify(manifest)
|
return jsonify(manifest)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/sw.js")
|
@app.route("/sw.js")
|
||||||
def pw():
|
def pw():
|
||||||
return send_from_directory("pwa", "sw.js")
|
return send_from_directory("pwa", "sw.js")
|
||||||
@@ -327,7 +332,6 @@ def donateAPI():
|
|||||||
}
|
}
|
||||||
response = make_response(jsonify(data), 200, headers)
|
response = make_response(jsonify(data), 200, headers)
|
||||||
|
|
||||||
|
|
||||||
if request.method == "OPTIONS":
|
if request.method == "OPTIONS":
|
||||||
response.headers["Access-Control-Allow-Origin"] = "*"
|
response.headers["Access-Control-Allow-Origin"] = "*"
|
||||||
response.headers["Access-Control-Allow-Methods"] = "GET, POST, PUT, OPTIONS"
|
response.headers["Access-Control-Allow-Methods"] = "GET, POST, PUT, OPTIONS"
|
||||||
@@ -374,13 +378,14 @@ def donateAmountPost(amount):
|
|||||||
if amount < 0.0001:
|
if amount < 0.0001:
|
||||||
return jsonify({"message": "Error: Amount too small"}), 400, headers
|
return jsonify({"message": "Error: Amount too small"}), 400, headers
|
||||||
|
|
||||||
|
|
||||||
# Create transaction
|
# Create transaction
|
||||||
sender = Pubkey.from_string(sender)
|
sender = Pubkey.from_string(sender)
|
||||||
receiver = Pubkey.from_string("AJsPEEe6S7XSiVcdZKbeV8GRp1QuhFUsG8mLrqL4XgiU")
|
receiver = Pubkey.from_string(
|
||||||
|
"AJsPEEe6S7XSiVcdZKbeV8GRp1QuhFUsG8mLrqL4XgiU")
|
||||||
transfer_ix = transfer(
|
transfer_ix = transfer(
|
||||||
TransferParams(
|
TransferParams(
|
||||||
from_pubkey=sender, to_pubkey=receiver, lamports=int(amount * 1000000000)
|
from_pubkey=sender, to_pubkey=receiver, lamports=int(
|
||||||
|
amount * 1000000000)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
solana_client = Client("https://api.mainnet-beta.solana.com")
|
solana_client = Client("https://api.mainnet-beta.solana.com")
|
||||||
@@ -408,6 +413,7 @@ def donateAmountPost(amount):
|
|||||||
def version():
|
def version():
|
||||||
return jsonify({"version": getVersion()})
|
return jsonify({"version": getVersion()})
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/help")
|
@app.route("/api/help")
|
||||||
def help():
|
def help():
|
||||||
return jsonify({
|
return jsonify({
|
||||||
@@ -424,8 +430,6 @@ def help():
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/time")
|
@app.route("/api/time")
|
||||||
def time():
|
def time():
|
||||||
timezone_offset = datetime.timedelta(hours=ncConfig["time-zone"])
|
timezone_offset = datetime.timedelta(hours=ncConfig["time-zone"])
|
||||||
@@ -443,11 +447,13 @@ def time():
|
|||||||
def timezone():
|
def timezone():
|
||||||
return jsonify({"timezone": ncConfig["time-zone"]})
|
return jsonify({"timezone": ncConfig["time-zone"]})
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/timezone", methods=["POST"])
|
@app.route("/api/timezone", methods=["POST"])
|
||||||
def timezonePost():
|
def timezonePost():
|
||||||
# Refresh config
|
# Refresh config
|
||||||
global ncConfig
|
global ncConfig
|
||||||
conf = requests.get("https://cloud.woodburn.au/s/4ToXgFe3TnnFcN7/download/website-conf.json")
|
conf = requests.get(
|
||||||
|
"https://cloud.woodburn.au/s/4ToXgFe3TnnFcN7/download/website-conf.json")
|
||||||
if conf.status_code != 200:
|
if conf.status_code != 200:
|
||||||
return jsonify({"message": "Error: Could not get timezone"})
|
return jsonify({"message": "Error: Could not get timezone"})
|
||||||
if not conf.json():
|
if not conf.json():
|
||||||
@@ -459,10 +465,12 @@ def timezonePost():
|
|||||||
ncConfig = conf
|
ncConfig = conf
|
||||||
return jsonify({"message": "Successfully pulled latest timezone", "timezone": ncConfig["time-zone"]})
|
return jsonify({"message": "Successfully pulled latest timezone", "timezone": ncConfig["time-zone"]})
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/message")
|
@app.route("/api/message")
|
||||||
def nc():
|
def nc():
|
||||||
return jsonify({"message": ncConfig["message"]})
|
return jsonify({"message": ncConfig["message"]})
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/ip")
|
@app.route("/api/ip")
|
||||||
def ip():
|
def ip():
|
||||||
return jsonify({"ip": getClientIP(request)})
|
return jsonify({"ip": getClientIP(request)})
|
||||||
@@ -479,6 +487,12 @@ def email():
|
|||||||
|
|
||||||
# Check if api key sent
|
# Check if api key sent
|
||||||
data = request.json
|
data = request.json
|
||||||
|
if not data:
|
||||||
|
return jsonify({
|
||||||
|
"status": 400,
|
||||||
|
"error": "Bad request JSON Data missing"
|
||||||
|
})
|
||||||
|
|
||||||
if "key" not in data:
|
if "key" not in data:
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"status": 401,
|
"status": 401,
|
||||||
@@ -493,6 +507,7 @@ def email():
|
|||||||
|
|
||||||
return sendEmail(data)
|
return sendEmail(data)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api/v1/project")
|
@app.route("/api/v1/project")
|
||||||
def getCurrentProject():
|
def getCurrentProject():
|
||||||
try:
|
try:
|
||||||
@@ -524,8 +539,6 @@ def getCurrentProject():
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
@@ -553,11 +566,10 @@ def index():
|
|||||||
if request.args.get("load"):
|
if request.args.get("load"):
|
||||||
loaded = False
|
loaded = False
|
||||||
|
|
||||||
|
|
||||||
# Check if crawler
|
# Check if crawler
|
||||||
if request.headers and request.headers.get("User-Agent"):
|
if request.headers and request.headers.get("User-Agent"):
|
||||||
# Check if curl
|
# Check if curl
|
||||||
if "curl" in request.headers.get("User-Agent"):
|
if "curl" in request.headers.get("User-Agent", "curl"):
|
||||||
return jsonify(
|
return jsonify(
|
||||||
{
|
{
|
||||||
"message": "Welcome to Nathan.Woodburn/! This is a personal website. For more information, visit https://nathan.woodburn.au",
|
"message": "Welcome to Nathan.Woodburn/! This is a personal website. For more information, visit https://nathan.woodburn.au",
|
||||||
@@ -568,8 +580,8 @@ def index():
|
|||||||
)
|
)
|
||||||
|
|
||||||
if "Googlebot" not in request.headers.get(
|
if "Googlebot" not in request.headers.get(
|
||||||
"User-Agent"
|
"User-Agent", ""
|
||||||
) and "Bingbot" not in request.headers.get("User-Agent"):
|
) and "Bingbot" not in request.headers.get("User-Agent", ""):
|
||||||
# Check if cookie is set
|
# Check if cookie is set
|
||||||
if not loaded:
|
if not loaded:
|
||||||
# Set cookie
|
# Set cookie
|
||||||
@@ -631,9 +643,11 @@ def index():
|
|||||||
or project["avatar_url"] == ""
|
or project["avatar_url"] == ""
|
||||||
):
|
):
|
||||||
project["avatar_url"] = "/favicon.png"
|
project["avatar_url"] = "/favicon.png"
|
||||||
project["name"] = project["name"].replace("_", " ").replace("-", " ")
|
project["name"] = project["name"].replace(
|
||||||
|
"_", " ").replace("-", " ")
|
||||||
# Sort by last updated
|
# Sort by last updated
|
||||||
projectsList = sorted(projects, key=lambda x: x["updated_at"], reverse=True)
|
projectsList = sorted(
|
||||||
|
projects, key=lambda x: x["updated_at"], reverse=True)
|
||||||
projects = []
|
projects = []
|
||||||
projectNames = []
|
projectNames = []
|
||||||
projectNum = 0
|
projectNum = 0
|
||||||
@@ -646,7 +660,8 @@ def index():
|
|||||||
|
|
||||||
custom = ""
|
custom = ""
|
||||||
# Check for downtime
|
# Check for downtime
|
||||||
uptime = requests.get("https://uptime.woodburn.au/api/status-page/main/badge")
|
uptime = requests.get(
|
||||||
|
"https://uptime.woodburn.au/api/status-page/main/badge")
|
||||||
uptime = uptime.content.count(b"Up") > 1
|
uptime = uptime.content.count(b"Up") > 1
|
||||||
|
|
||||||
if uptime:
|
if uptime:
|
||||||
@@ -787,6 +802,7 @@ def now_old():
|
|||||||
"now/old.html", handshake_scripts=handshake_scripts, now_pages=html
|
"now/old.html", handshake_scripts=handshake_scripts, now_pages=html
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/now.rss")
|
@app.route("/now.rss")
|
||||||
@app.route("/now.xml")
|
@app.route("/now.xml")
|
||||||
@app.route("/rss.xml")
|
@app.route("/rss.xml")
|
||||||
@@ -805,18 +821,22 @@ def now_rss():
|
|||||||
rss += "</channel></rss>"
|
rss += "</channel></rss>"
|
||||||
return make_response(rss, 200, {"Content-Type": "application/rss+xml"})
|
return make_response(rss, 200, {"Content-Type": "application/rss+xml"})
|
||||||
|
|
||||||
|
|
||||||
@app.route("/now.json")
|
@app.route("/now.json")
|
||||||
def now_json():
|
def now_json():
|
||||||
now_pages = now.list_now_page_files()
|
now_pages = now.list_now_page_files()
|
||||||
host = "https://" + request.host
|
host = "https://" + request.host
|
||||||
if ":" in request.host:
|
if ":" in request.host:
|
||||||
host = "http://" + request.host
|
host = "http://" + request.host
|
||||||
now_pages = [{"url":host+"/now/"+page.strip(".html"), "date":datetime.datetime.strptime(page.strip(".html"), "%y_%m_%d").strftime("%A, %B %d, %Y"), "title":"What's Happening "+datetime.datetime.strptime(page.strip(".html"), "%y_%m_%d").strftime("%A, %B %d, %Y")} for page in now_pages]
|
now_pages = [{"url": host+"/now/"+page.strip(".html"), "date": datetime.datetime.strptime(page.strip(".html"), "%y_%m_%d").strftime(
|
||||||
|
"%A, %B %d, %Y"), "title": "What's Happening "+datetime.datetime.strptime(page.strip(".html"), "%y_%m_%d").strftime("%A, %B %d, %Y")} for page in now_pages]
|
||||||
return jsonify(now_pages)
|
return jsonify(now_pages)
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
# region blog Pages
|
# region blog Pages
|
||||||
|
|
||||||
|
|
||||||
@app.route("/blog")
|
@app.route("/blog")
|
||||||
@app.route("/blog/")
|
@app.route("/blog/")
|
||||||
def blog_page():
|
def blog_page():
|
||||||
@@ -851,7 +871,6 @@ def blog_path(path):
|
|||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# region Donate
|
# region Donate
|
||||||
@app.route("/donate")
|
@app.route("/donate")
|
||||||
def donate():
|
def donate():
|
||||||
@@ -980,10 +999,10 @@ def donate():
|
|||||||
|
|
||||||
|
|
||||||
@app.route("/address/<path:address>")
|
@app.route("/address/<path:address>")
|
||||||
def addressQR(address:str):
|
def addressQR(address):
|
||||||
qr = qrcode.QRCode(
|
qr = qrcode.QRCode(
|
||||||
version=1,
|
version=1,
|
||||||
error_correction=qrcode.constants.ERROR_CORRECT_L,
|
error_correction=ERROR_CORRECT_L,
|
||||||
box_size=10,
|
box_size=10,
|
||||||
border=4,
|
border=4,
|
||||||
)
|
)
|
||||||
@@ -993,7 +1012,7 @@ def addressQR(address:str):
|
|||||||
|
|
||||||
# Save the QR code image to a temporary file
|
# Save the QR code image to a temporary file
|
||||||
qr_image_path = "/tmp/qr_code.png"
|
qr_image_path = "/tmp/qr_code.png"
|
||||||
qr_image.save(qr_image_path)
|
qr_image.save(qr_image_path) # type: ignore
|
||||||
|
|
||||||
# Return the QR code image as a response
|
# Return the QR code image as a response
|
||||||
return send_file(qr_image_path, mimetype="image/png")
|
return send_file(qr_image_path, mimetype="image/png")
|
||||||
@@ -1001,12 +1020,14 @@ def addressQR(address:str):
|
|||||||
|
|
||||||
@app.route("/qrcode/<path:data>")
|
@app.route("/qrcode/<path:data>")
|
||||||
@app.route("/qr/<path:data>")
|
@app.route("/qr/<path:data>")
|
||||||
def qr(data:str):
|
def qr_code(data):
|
||||||
qr = qrcode.QRCode(error_correction=qrcode.constants.ERROR_CORRECT_H,box_size=10,border=2)
|
qr = qrcode.QRCode(
|
||||||
|
error_correction=ERROR_CORRECT_H, box_size=10, border=2)
|
||||||
qr.add_data(data)
|
qr.add_data(data)
|
||||||
qr.make()
|
qr.make()
|
||||||
|
|
||||||
qr_image:Image.Image = qr.make_image(fill_color="black", back_color="white").convert('RGB')
|
qr_image: Image.Image = qr.make_image(
|
||||||
|
fill_color="black", back_color="white").convert('RGB') # type: ignore
|
||||||
|
|
||||||
# Add logo
|
# Add logo
|
||||||
logo = Image.open("templates/assets/img/favicon/logo.png")
|
logo = Image.open("templates/assets/img/favicon/logo.png")
|
||||||
@@ -1018,7 +1039,6 @@ def qr(data:str):
|
|||||||
(qr_image.size[1] - logo.size[1]) // 2)
|
(qr_image.size[1] - logo.size[1]) // 2)
|
||||||
qr_image.paste(logo, pos, mask=logo)
|
qr_image.paste(logo, pos, mask=logo)
|
||||||
|
|
||||||
|
|
||||||
qr_image.save("/tmp/qr_code.png")
|
qr_image.save("/tmp/qr_code.png")
|
||||||
return send_file("/tmp/qr_code.png", mimetype="image/png")
|
return send_file("/tmp/qr_code.png", mimetype="image/png")
|
||||||
|
|
||||||
@@ -1037,6 +1057,7 @@ def supersecretpath():
|
|||||||
ascii_art_html = converter.convert(ascii_art)
|
ascii_art_html = converter.convert(ascii_art)
|
||||||
return render_template("ascii.html", ascii_art=ascii_art_html)
|
return render_template("ascii.html", ascii_art=ascii_art_html)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/download/<path:path>")
|
@app.route("/download/<path:path>")
|
||||||
def download(path):
|
def download(path):
|
||||||
# Check if file exists
|
# Check if file exists
|
||||||
@@ -1046,16 +1067,17 @@ def download(path):
|
|||||||
return send_file(path)
|
return send_file(path)
|
||||||
return render_template("404.html"), 404
|
return render_template("404.html"), 404
|
||||||
|
|
||||||
|
|
||||||
@app.route("/.well-known/<path:path>")
|
@app.route("/.well-known/<path:path>")
|
||||||
def wellknown(path):
|
def wellknown(path):
|
||||||
return send_from_directory(".well-known", path)
|
return send_from_directory(".well-known", path)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/hosting/send-enquiry", methods=["POST"])
|
@app.route("/hosting/send-enquiry", methods=["POST"])
|
||||||
def hosting_send_enquiry():
|
def hosting_send_enquiry():
|
||||||
global email_request_count
|
global email_request_count
|
||||||
global ip_request_count
|
global ip_request_count
|
||||||
|
|
||||||
|
|
||||||
if not request.json:
|
if not request.json:
|
||||||
return jsonify({"status": "error", "message": "No JSON data provided"}), 400
|
return jsonify({"status": "error", "message": "No JSON data provided"}), 400
|
||||||
|
|
||||||
@@ -1077,7 +1099,8 @@ def hosting_send_enquiry():
|
|||||||
if email in email_request_count:
|
if email in email_request_count:
|
||||||
if (current_time - email_request_count[email]["last_reset"]) > RATE_LIMIT_WINDOW:
|
if (current_time - email_request_count[email]["last_reset"]) > RATE_LIMIT_WINDOW:
|
||||||
# Reset counter if the time window has passed
|
# Reset counter if the time window has passed
|
||||||
email_request_count[email] = {"count": 1, "last_reset": current_time}
|
email_request_count[email] = {
|
||||||
|
"count": 1, "last_reset": current_time}
|
||||||
else:
|
else:
|
||||||
# Increment counter
|
# Increment counter
|
||||||
email_request_count[email]["count"] += 1
|
email_request_count[email]["count"] += 1
|
||||||
@@ -1124,7 +1147,6 @@ def hosting_send_enquiry():
|
|||||||
except:
|
except:
|
||||||
return jsonify({"status": "error", "message": "Invalid data types"}), 400
|
return jsonify({"status": "error", "message": "Invalid data types"}), 400
|
||||||
|
|
||||||
|
|
||||||
# Basic validation
|
# Basic validation
|
||||||
if not isinstance(cpus, int) or cpus < 1 or cpus > 64:
|
if not isinstance(cpus, int) or cpus < 1 or cpus > 64:
|
||||||
return jsonify({"status": "error", "message": "Invalid CPUs"}), 400
|
return jsonify({"status": "error", "message": "Invalid CPUs"}), 400
|
||||||
@@ -1139,8 +1161,6 @@ def hosting_send_enquiry():
|
|||||||
if not isinstance(email, str) or len(email) > 100 or "@" not in email:
|
if not isinstance(email, str) or len(email) > 100 or "@" not in email:
|
||||||
return jsonify({"status": "error", "message": "Invalid email"}), 400
|
return jsonify({"status": "error", "message": "Invalid email"}), 400
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Send to Discord webhook
|
# Send to Discord webhook
|
||||||
webhook_url = os.getenv("HOSTING_WEBHOOK")
|
webhook_url = os.getenv("HOSTING_WEBHOOK")
|
||||||
if not webhook_url:
|
if not webhook_url:
|
||||||
@@ -1206,7 +1226,7 @@ def catch_all(path: str):
|
|||||||
|
|
||||||
if request.headers:
|
if request.headers:
|
||||||
# Check if curl
|
# Check if curl
|
||||||
if "curl" in request.headers.get("User-Agent"):
|
if "curl" in request.headers.get("User-Agent", "curl"):
|
||||||
return jsonify(
|
return jsonify(
|
||||||
{
|
{
|
||||||
"status": 404,
|
"status": 404,
|
||||||
@@ -1216,6 +1236,7 @@ def catch_all(path: str):
|
|||||||
), 404
|
), 404
|
||||||
return render_template("404.html"), 404
|
return render_template("404.html"), 404
|
||||||
|
|
||||||
|
|
||||||
@app.route("/resume.pdf")
|
@app.route("/resume.pdf")
|
||||||
def resume_pdf():
|
def resume_pdf():
|
||||||
# Check if file exists
|
# Check if file exists
|
||||||
@@ -1248,11 +1269,11 @@ def hnsdoh_acme():
|
|||||||
|
|
||||||
cf = Cloudflare(api_token=os.getenv("CF_TOKEN"))
|
cf = Cloudflare(api_token=os.getenv("CF_TOKEN"))
|
||||||
zone = cf.zones.list(name="hnsdoh.com").to_dict()
|
zone = cf.zones.list(name="hnsdoh.com").to_dict()
|
||||||
zone_id = zone["result"][0]["id"]
|
zone_id = zone["result"][0]["id"] # type: ignore
|
||||||
existing_records = cf.dns.records.list(
|
existing_records = cf.dns.records.list(
|
||||||
zone_id=zone_id, type="TXT", name="_acme-challenge.hnsdoh.com"
|
zone_id=zone_id, type="TXT", name="_acme-challenge.hnsdoh.com" # type: ignore
|
||||||
).to_dict()
|
).to_dict()
|
||||||
record_id = existing_records["result"][0]["id"]
|
record_id = existing_records["result"][0]["id"] # type: ignore
|
||||||
cf.dns.records.delete(dns_record_id=record_id, zone_id=zone_id)
|
cf.dns.records.delete(dns_record_id=record_id, zone_id=zone_id)
|
||||||
cf.dns.records.create(
|
cf.dns.records.create(
|
||||||
zone_id=zone_id,
|
zone_id=zone_id,
|
||||||
@@ -1321,7 +1342,7 @@ def podsync():
|
|||||||
def not_found(e):
|
def not_found(e):
|
||||||
if request.headers:
|
if request.headers:
|
||||||
# Check if curl
|
# Check if curl
|
||||||
if "curl" in request.headers.get("User-Agent"):
|
if "curl" in request.headers.get("User-Agent", "curl"):
|
||||||
return jsonify(
|
return jsonify(
|
||||||
{
|
{
|
||||||
"status": 404,
|
"status": 404,
|
||||||
|
|||||||
Reference in New Issue
Block a user