diff --git a/.gitignore b/.gitignore index 6b18607..7ddc266 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # Remove all development files uploads/ -static/css/* +static/theme/* # remove all PyCharm files .idea diff --git a/app.py b/app.py index d01f2e8..803cee3 100644 --- a/app.py +++ b/app.py @@ -2,10 +2,10 @@ print(""" ___ _ _ / _ \ _ __ | |_ _| | ___ __ _ ___ | | | | '_ \| | | | | | / _ \/ _` / __| -| |_| | | | | | |_| | |__| __/ (_| \__ \\ +| |_| | | | | | |_| | |__| __/ (_| \__ \ \___/|_| |_|_|\__, |_____\___|\__, |___/ |___/ |___/ -Created by Fluffy Bean - Version: 080123 +Created by Fluffy Bean - Version 080123 """) # Import base packages @@ -74,6 +74,10 @@ def internal_server_error(e): def home(): return render_template('home.html') +@app.route('/upload') +def upload(): + return render_template('upload.html') + @app.route('/image/') def image(request_id): # Check if request_id is valid diff --git a/packages/onlylegsDB.py b/packages/onlylegsDB.py index 6e40429..547d379 100644 --- a/packages/onlylegsDB.py +++ b/packages/onlylegsDB.py @@ -12,19 +12,16 @@ class DBmanager(): except ImportError: print("Error: could not import required packages") sys.exit(1) + + env_path = os.path.join('usr', '.env') + if not os.path.exists(env_path): + print("Error: could not find .env file") + sys.exit(1) + load_dotenv(env_path) + print(f"{now.hour}:{now.minute}:{now.second} - Connecting to database...") + try: - env_path = os.path.join('usr', '.env') - - if not os.path.exists(env_path): - print("Error: could not find .env file") - print("Exiting...") - sys.exit(1) - - load_dotenv(env_path) - print("### OnlyLegs Database Manager ###") - print(f"{now.hour}:{now.minute}:{now.second} - Connecting to database...") - database = mysql.connector.connect(host=os.environ.get('DB_HOST'), port=os.environ.get('DB_PORT'), database=os.environ.get('DB_NAME'), @@ -46,52 +43,42 @@ class DBmanager(): except Error as e: print("Error while connecting to Database!\nFull error:", e) - print("Exiting...") sys.exit(1) self.database = database def initialize(self): - dir = os.path.join('packages', 'tables') - - if not os.path.exists(dir+'/generate.sql'): + if not os.path.exists(os.path.join('packages', 'tables', 'generate.sql')): print("Error: could not find tables directory") - print("Exiting...") sys.exit(1) else: print(f"{now.hour}:{now.minute}:{now.second} - Initializing tables...") - with open(dir+'/generate.sql', 'r') as f: - sql = f.read() - + with open(os.path.join('packages', 'tables', 'generate.sql'), 'r') as sql: cursor = self.database.cursor() - query = cursor.execute(sql, multi=True) + query = cursor.execute(sql.read(), multi=True) + i = 0 for res in query: - #print("Running query...") - print(f"Affected {res.rowcount} rows") - - self.database.commit() + print(f"Query {i+1}: Affected {res.rowcount} rows") + i += 1 - if not os.path.exists(dir+'/junctions.sql'): + if not os.path.exists(os.path.join('packages', 'tables', 'junctions.sql')): print("Error: could not find junctions directory") - print("Exiting...") sys.exit(1) else: print(f"{now.hour}:{now.minute}:{now.second} - Initializing junctions...") - with open(dir+'/junctions.sql', 'r') as f: - sql = f.read() - + with open(os.path.join('packages', 'tables', 'junctions.sql'), 'r') as sql: cursor = self.database.cursor() - query = cursor.execute(sql, multi=True) + query = cursor.execute(sql.read(), multi=True) + i = 0 for res in query: - #print("Running query...") - print(f"Affected {res.rowcount} rows") - - self.database.commit() - + print(f"Query {i+1}: Affected {res.rowcount} rows") + i += 1 + + self.database.commit() print(f"{now.hour}:{now.minute}:{now.second} - Done!\n") def getImage(self, id): @@ -101,4 +88,4 @@ class DBmanager(): cursor = self.database.cursor() cursor.execute(sql, img) - return cursor.fetchone() \ No newline at end of file + return cursor.fetchone() diff --git a/packages/onlylegsSass.py b/packages/onlylegsSass.py index e6d2bc1..7b5fc65 100644 --- a/packages/onlylegsSass.py +++ b/packages/onlylegsSass.py @@ -13,7 +13,6 @@ class Sassy(): import sass except ImportError: print("Could not find libsass!") - print("Exiting...") sys.exit(1) theme_path = os.path.join('usr', 'themes', theme, 'style.scss') @@ -24,7 +23,6 @@ class Sassy(): self.loadTheme(theme_path) else: print("No theme found!") - print("Exiting...") sys.exit(1) font_path = os.path.join('usr', 'themes', theme, 'fonts') @@ -38,17 +36,16 @@ class Sassy(): print(f"{now.hour}:{now.minute}:{now.second} - Done!\n") def loadTheme (self, theme): - with open('static/css/style.css', 'w') as f: + with open('static/theme/style.css', 'w') as f: try: f.write(self.sass.compile(filename=theme, output_style='compressed')) print("Compiled successfully to:", f.name) except self.sass.CompileError as e: print("Failed to compile!\nFull error:", e) - print("Exiting...") sys.exit(1) def loadFonts (self, font_path): - dest = os.path.join('static', 'css', 'fonts') + dest = os.path.join('static', 'theme', 'fonts') if os.path.exists(dest): print("Removing old fonts...") @@ -57,7 +54,6 @@ class Sassy(): print("Removed old fonts!") except Exception as e: print("Failed to remove old fonts!\nFull error:", e) - print("Exiting...") sys.exit(1) try: @@ -65,7 +61,6 @@ class Sassy(): print("Copied fonts to:", dest) except Exception as e: print("Failed to copy fonts!\nFull error:", e) - print("Exiting...") sys.exit(1) #print ("Removing old fonts from:", dest) diff --git a/templates/home.html b/templates/home.html index 51902de..2b57ba9 100644 --- a/templates/home.html +++ b/templates/home.html @@ -1,7 +1,7 @@ {% extends 'layout.html' %} {% block content %}
- leaves + leaves
diff --git a/templates/layout.html b/templates/layout.html index 63f4e36..69c2d2f 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -4,30 +4,31 @@ Gallery - + -