Fixed multiple requests for images

Started adding SQL table layouts
Making package loading prettier
This commit is contained in:
Michał Gdula 2023-01-06 15:47:58 +00:00
parent 5951baadaf
commit a7e79ab5a5
10 changed files with 60 additions and 75 deletions

View file

@ -1,3 +1,4 @@
import time
import sys
import os
@ -8,19 +9,19 @@ class DBmanager():
from mysql.connector import Error
from dotenv import load_dotenv
except ImportError:
print("Error: could not import required modules")
print("Error: could not import required packages")
sys.exit(1)
try:
load_dotenv(os.path.join('usr', '.env'))
print("### OnlyLegs Database Manager ###")
print("Connecting to database...")
print("Connecting to MySQL database...")
database = mysql.connector.connect(host=os.environ.get('HOST'),
port=os.environ.get('PORT'),
database=os.environ.get('DATABASE'),
user=os.environ.get('USERNAME'),
password=os.environ.get('PASSWORD')
database = mysql.connector.connect(host=os.environ.get('DB_HOST'),
port=os.environ.get('DB_PORT'),
database=os.environ.get('DB_NAME'),
user=os.environ.get('DB_USER'),
password=os.environ.get('DB_PASS')
)
if database.is_connected():
@ -32,9 +33,12 @@ class DBmanager():
record = cursor.fetchone()
print("Connected to database:", record[0])
print("Finished\n")
except Error as e:
print("Error while connecting to MySQL!\n", e)
print("Error while connecting to Database! Full error:\n", e)
print("Exiting...")
sys.exit(1)
self.database = database

View file

@ -1,12 +1,16 @@
import time
import sys
import os
class Sassy():
def __init__(self, theme):
print("### OnlyLegs Theme Manager ###")
try:
import sass
except ImportError:
print("Error: libsass not found")
print("Could not find libsass!")
print("Exiting...")
sys.exit(1)
path_to_sass = os.path.join('usr', 'themes', theme, 'style.scss')
@ -16,13 +20,17 @@ class Sassy():
self.sass = sass
self.loadTheme(path_to_sass)
else:
print("Error: theme not found")
print("No theme found!")
print("Exiting...")
sys.exit(1)
def loadTheme (self, theme):
with open('static/css/style.css', 'w') as f:
try:
f.write(self.sass.compile(filename=theme, output_style='compressed'))
print("Sass compiled successfully to:", f.name)
print("Compiled successfully to:", f.name)#
print("Finished\n")
except self.sass.CompileError as e:
print("Error: sass compilation failed:\n", e)
print("Failed to compile! Full error:\n", e)
print("Exiting...")
sys.exit(1)

View file

View file

@ -0,0 +1,7 @@
CREATE IF NOT EXISTS TABLE abilities (
id INT(69) PRIMARY KEY AUTO_INCREMENT,
user INT(69) NOT NULL,
admin BOOLEAN NOT NULL DEFAULT FALSE,
create_posts BOOLEAN NOT NULL DEFAULT TRUE,
updated_at TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW()
);

View file

@ -0,0 +1,8 @@
CREATE IF NOT EXISTS TABLE users (
id INT(69) PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW()
);