fix: Cleanup code to follow linting
This commit is contained in:
3
blog.py
3
blog.py
@@ -1,9 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
from flask import render_template
|
from flask import render_template
|
||||||
from datetime import datetime
|
|
||||||
import markdown
|
import markdown
|
||||||
from markdown.extensions.codehilite import CodeHiliteExtension
|
|
||||||
from markdown.extensions.fenced_code import FencedCodeExtension
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|||||||
6
main.py
6
main.py
@@ -1,12 +1,6 @@
|
|||||||
import time
|
|
||||||
from flask import Flask
|
|
||||||
from server import app
|
from server import app
|
||||||
import server
|
|
||||||
from gunicorn.app.base import BaseApplication
|
from gunicorn.app.base import BaseApplication
|
||||||
import os
|
import os
|
||||||
import dotenv
|
|
||||||
import sys
|
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
class GunicornApp(BaseApplication):
|
class GunicornApp(BaseApplication):
|
||||||
|
|||||||
2
now.py
2
now.py
@@ -30,7 +30,7 @@ def render_now_page(date,handshake_scripts=None):
|
|||||||
# Remove .html
|
# Remove .html
|
||||||
date = date.removesuffix(".html")
|
date = date.removesuffix(".html")
|
||||||
|
|
||||||
if not date in list_now_dates():
|
if date not in list_now_dates():
|
||||||
return render_template("404.html"), 404
|
return render_template("404.html"), 404
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
24
server.py
24
server.py
@@ -17,9 +17,6 @@ from cloudflare import Cloudflare
|
|||||||
import datetime
|
import datetime
|
||||||
import qrcode
|
import qrcode
|
||||||
from qrcode.constants import ERROR_CORRECT_L, ERROR_CORRECT_H
|
from qrcode.constants import ERROR_CORRECT_L, ERROR_CORRECT_H
|
||||||
import re
|
|
||||||
import binascii
|
|
||||||
import base64
|
|
||||||
from ansi2html import Ansi2HTMLConverter
|
from ansi2html import Ansi2HTMLConverter
|
||||||
from functools import cache
|
from functools import cache
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
@@ -63,7 +60,7 @@ if os.path.isfile("data/sites.json"):
|
|||||||
sites = json.load(file)
|
sites = json.load(file)
|
||||||
# Remove any sites that are not enabled
|
# Remove any sites that are not enabled
|
||||||
sites = [
|
sites = [
|
||||||
site for site in sites if "enabled" not in site or site["enabled"] == True
|
site for site in sites if "enabled" not in site or site["enabled"]
|
||||||
]
|
]
|
||||||
|
|
||||||
projects = []
|
projects = []
|
||||||
@@ -356,7 +353,7 @@ def sol_donate_post(amount):
|
|||||||
# Make sure amount is a number
|
# Make sure amount is a number
|
||||||
try:
|
try:
|
||||||
amount = float(amount)
|
amount = float(amount)
|
||||||
except:
|
except ValueError:
|
||||||
return jsonify({"message": "Error: Invalid amount"}), 400, SOLANA_HEADERS
|
return jsonify({"message": "Error: Invalid amount"}), 400, SOLANA_HEADERS
|
||||||
|
|
||||||
if amount < 0.0001:
|
if amount < 0.0001:
|
||||||
@@ -375,7 +372,6 @@ def sol_donate_post(amount):
|
|||||||
def api_version_get():
|
def api_version_get():
|
||||||
return jsonify({"version": getGitCommit()})
|
return jsonify({"version": getGitCommit()})
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api")
|
@app.route("/api")
|
||||||
@app.route("/api/")
|
@app.route("/api/")
|
||||||
@app.route("/api/v1")
|
@app.route("/api/v1")
|
||||||
@@ -493,7 +489,7 @@ def api_project_get():
|
|||||||
repo_name = git["repo"]["name"]
|
repo_name = git["repo"]["name"]
|
||||||
repo_name = repo_name.lower()
|
repo_name = repo_name.lower()
|
||||||
repo_description = git["repo"]["description"]
|
repo_description = git["repo"]["description"]
|
||||||
except:
|
except Exception as e:
|
||||||
repo_name = "nathanwoodburn.github.io"
|
repo_name = "nathanwoodburn.github.io"
|
||||||
repo_description = "Personal website"
|
repo_description = "Personal website"
|
||||||
git = {
|
git = {
|
||||||
@@ -503,7 +499,7 @@ def api_project_get():
|
|||||||
"description": "Personal website",
|
"description": "Personal website",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print("Error getting git data")
|
print(f"Error getting git data: {e}")
|
||||||
|
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"repo_name": repo_name,
|
"repo_name": repo_name,
|
||||||
@@ -600,7 +596,7 @@ def index_get():
|
|||||||
repo_name = git["repo"]["name"]
|
repo_name = git["repo"]["name"]
|
||||||
repo_name = repo_name.lower()
|
repo_name = repo_name.lower()
|
||||||
repo_description = git["repo"]["description"]
|
repo_description = git["repo"]["description"]
|
||||||
except:
|
except Exception as e:
|
||||||
repo_name = "nathanwoodburn.github.io"
|
repo_name = "nathanwoodburn.github.io"
|
||||||
repo_description = "Personal website"
|
repo_description = "Personal website"
|
||||||
git = {
|
git = {
|
||||||
@@ -610,7 +606,7 @@ def index_get():
|
|||||||
"description": "Personal website",
|
"description": "Personal website",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print("Error getting git data")
|
print(f"Error getting git data: {e}")
|
||||||
|
|
||||||
# Get only repo names for the newest updates
|
# Get only repo names for the newest updates
|
||||||
if projects == [] or projectsUpdated < (datetime.datetime.now() - datetime.timedelta(
|
if projects == [] or projectsUpdated < (datetime.datetime.now() - datetime.timedelta(
|
||||||
@@ -965,9 +961,9 @@ def donate_get():
|
|||||||
else:
|
else:
|
||||||
cryptoHTML += f"<br>Invalid chain: {crypto}<br>"
|
cryptoHTML += f"<br>Invalid chain: {crypto}<br>"
|
||||||
|
|
||||||
if os.path.isfile(f".well-known/wallets/.domains"):
|
if os.path.isfile(".well-known/wallets/.domains"):
|
||||||
# Get json of all domains
|
# Get json of all domains
|
||||||
with open(f".well-known/wallets/.domains") as file:
|
with open(".well-known/wallets/.domains") as file:
|
||||||
domains = file.read()
|
domains = file.read()
|
||||||
domains = json.loads(domains)
|
domains = json.loads(domains)
|
||||||
|
|
||||||
@@ -1097,7 +1093,7 @@ def hosting_post():
|
|||||||
if email_request_count[email]["count"] > EMAIL_RATE_LIMIT:
|
if email_request_count[email]["count"] > EMAIL_RATE_LIMIT:
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"status": "error",
|
"status": "error",
|
||||||
"message": f"Rate limit exceeded. Please try again later."
|
"message": "Rate limit exceeded. Please try again later."
|
||||||
}), 429
|
}), 429
|
||||||
else:
|
else:
|
||||||
# First request for this email
|
# First request for this email
|
||||||
@@ -1134,7 +1130,7 @@ def hosting_post():
|
|||||||
backups = backups in [True, "true", "True", 1, "1", "yes", "Yes"]
|
backups = backups in [True, "true", "True", 1, "1", "yes", "Yes"]
|
||||||
message = str(message)
|
message = str(message)
|
||||||
email = str(email)
|
email = str(email)
|
||||||
except:
|
except ValueError:
|
||||||
return jsonify({"status": "error", "message": "Invalid data types"}), 400
|
return jsonify({"status": "error", "message": "Invalid data types"}), 400
|
||||||
|
|
||||||
# Basic validation
|
# Basic validation
|
||||||
|
|||||||
3
sol.py
3
sol.py
@@ -1,9 +1,6 @@
|
|||||||
from solders.keypair import Keypair
|
|
||||||
from solders.pubkey import Pubkey
|
from solders.pubkey import Pubkey
|
||||||
from solana.rpc.api import Client
|
from solana.rpc.api import Client
|
||||||
from solders.system_program import TransferParams, transfer
|
from solders.system_program import TransferParams, transfer
|
||||||
from solders.transaction import Transaction
|
|
||||||
from solders.hash import Hash
|
|
||||||
from solders.message import MessageV0
|
from solders.message import MessageV0
|
||||||
from solders.transaction import VersionedTransaction
|
from solders.transaction import VersionedTransaction
|
||||||
from solders.null_signer import NullSigner
|
from solders.null_signer import NullSigner
|
||||||
|
|||||||
Reference in New Issue
Block a user