From b5dc2e1d01ac0b12f3febce0762cbcee602323ad Mon Sep 17 00:00:00 2001 From: Siarhei Siniak Date: Sun, 19 May 2024 13:18:46 +0300 Subject: [PATCH] [~] Refactor --- dotfiles/.local/bin/commands | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/dotfiles/.local/bin/commands b/dotfiles/.local/bin/commands index 584b201..e41484c 100755 --- a/dotfiles/.local/bin/commands +++ b/dotfiles/.local/bin/commands @@ -1117,6 +1117,15 @@ def http_server(argv): options.docker = True index_section = 'autoindex on;' + + if options.public: + options.token = 'public' + + location_section = 'location / {%s}' % index_section + else: + if options.token is None: + options.token = os.urandom(16).hex() + if options.docker: DATA_DIR = '/usr/share/nginx' APP_DIR = '/app' @@ -1126,12 +1135,7 @@ def http_server(argv): CONF_DIR = '/opt/nginx/%s/conf/' % options.token APP_DIR = os.path.abspath(os.path.curdir) - if options.public: - location_section = 'location / {%s}' % index_section - else: - if options.token is None: - options.token = os.urandom(16).hex() - + if not options.public: if not options.prefix is None: path = options.prefix + options.token else: