diff --git a/main.py b/main.py index 7c8962a..68ee378 100644 --- a/main.py +++ b/main.py @@ -23,6 +23,11 @@ STORAGE_ROOT = "" # Global DB connection DB_CONN = None +# Logging utility +def log(message): + if CONFIG.get("logging", {}).get("enabled", True): + print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] {message}") + # Load config def load_config(): global CONFIG, STORAGE_ROOT @@ -156,7 +161,7 @@ class FileServerHandler(BaseHTTPRequestHandler): def log_message(self, format, *args): # Override to avoid logging to stderr - pass + log(format % args) def send_html(self, content, status=200): self.send_response(status) @@ -185,25 +190,28 @@ class FileServerHandler(BaseHTTPRequestHandler): - {CONFIG['ui']['title']} + SimpliestFS -

{CONFIG['ui']['title']}

-

{CONFIG['ui']['disclaimer']}

+

SimpliestFS

+

EN: {CONFIG['ui']['disclaimer']}

+

RU: {CONFIG['ui']['disclaimer_ru']}

Contact: {CONFIG['ui']['contact_email']}

+

Contact (prefered): @justuser_31

Register Login Explore Files

- Note: All files are stored locally. No encryption. No external databases. + Note: NO ENCRYPTION, no external databases. As simple as possible.
@@ -215,14 +223,16 @@ class FileServerHandler(BaseHTTPRequestHandler): - Register - {CONFIG['ui']['title']} + Register - SimpliestFS -

Register

+

SimpliestFS

+

Register

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Back to Home

@@ -260,6 +270,11 @@ class FileServerHandler(BaseHTTPRequestHandler): self.send_html(content, 401) return + # If already authorized + username = self.get_session_user() + if username: + self.send_redirect("/files") + return # GET /login content = self.render_login_form() self.send_html(content) @@ -269,17 +284,19 @@ class FileServerHandler(BaseHTTPRequestHandler): - Login - {CONFIG['ui']['title']} + Login - SimpliestFS -

Login

+

SimpliestFS

+

Login

{f'

{error}

' if error else ''}
@@ -327,16 +344,18 @@ class FileServerHandler(BaseHTTPRequestHandler): - My Files - {CONFIG['ui']['title']} + My Files - SimpliestFS -

My Files

+

SimpliestFS

+

My Files

Quota: {CONFIG['storage']['default_quota_mb']} MB | Used: {used_mb:.2f} MB
@@ -346,7 +365,10 @@ class FileServerHandler(BaseHTTPRequestHandler):

{files_html if files_html else "

No files yet.

"} -

Logout

+

+ Logout + Back to Home +

""" @@ -495,14 +517,16 @@ class FileServerHandler(BaseHTTPRequestHandler): - Explore Files - {CONFIG['ui']['title']} + Explore Files - SimpliestFS -

Explore Files

+

SimpliestFS

+

Explore Files

All users:

{users_html if users_html else "

No users yet.

"}

Back to Home

@@ -536,14 +560,16 @@ class FileServerHandler(BaseHTTPRequestHandler): - {username}'s Files - {CONFIG['ui']['title']} + {username}'s Files - SimpliestFS -

{username}'s Files

+

SimpliestFS

+

{username}'s Files

{files_html if files_html else "

No files.

"}

Back to All Users

@@ -724,6 +750,9 @@ def main(): load_config() init_db() + # Log startup + log("Starting SimpliestFS server...") + # Start session cleanup thread cleanup_thread = threading.Thread(target=session_cleanup, daemon=True) cleanup_thread.start() @@ -731,6 +760,7 @@ def main(): # Start server server_address = (CONFIG["server"]["host"], CONFIG["server"]["port"]) httpd = HTTPServer(server_address, FileServerHandler) + log(f"SimpliestFS server running on {CONFIG['server']['host']}:{CONFIG['server']['port']}") httpd.serve_forever() if __name__ == "__main__":