From fc13ef570769ec58326e07ea1d683c4ac15d6b87 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Tue, 24 Jun 2014 15:08:39 -0400 Subject: [PATCH] merging in relevant work from #59 --- onionshare/onionshare.py | 6 +++--- onionshare_gui/webapp.py | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py index c1be52ef..d91aea88 100644 --- a/onionshare/onionshare.py +++ b/onionshare/onionshare.py @@ -58,7 +58,7 @@ def human_readable_filesize(b): @app.route("/{0}".format(slug)) def index(): - global filename, filesize, filehash, slug, strings, REQUEST_LOAD + global filename, filesize, filehash, slug, strings, REQUEST_LOAD, onionshare_dir add_request(REQUEST_LOAD, request.path) return render_template_string( open('{0}/index.html'.format(onionshare_dir)).read(), @@ -126,7 +126,7 @@ def download(): @app.errorhandler(404) def page_not_found(e): - global REQUEST_OTHER + global REQUEST_OTHER, onionshare_dir add_request(REQUEST_OTHER, request.path) return render_template_string(open('{0}/404.html'.format(onionshare_dir)).read()) @@ -239,7 +239,7 @@ def main(): filename = os.path.abspath(args.filename[0]) local_only = args.local_only - + global stay_open stay_open = args.stay_open diff --git a/onionshare_gui/webapp.py b/onionshare_gui/webapp.py index 80f2c3f8..db4bcc52 100644 --- a/onionshare_gui/webapp.py +++ b/onionshare_gui/webapp.py @@ -26,7 +26,17 @@ import logging log_handler = logging.FileHandler('{0}/onionshare.web.log'.format(temp_dir)) log_handler.setLevel(logging.WARNING) -app = Flask(__name__, template_folder='./templates') +template_folder = './templates' +if platform.system() == 'Windows': + # pyinstaller sets sys.frozen=1 on run + application_path = "" + if getattr(sys, "frozen", False): + application_path = os.path.dirname(sys.executable) + elif __file__: + application_path = os.path.dirname(__file__) + template_path = os.path.join(application_path, "templates") + +app = Flask(__name__, template_folder=template_path) app.logger.addHandler(log_handler) @app.route("/")