From baede536321431d5a19a2bb3ae659e875c2d9c63 Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Tue, 6 Mar 2018 02:06:44 -0800 Subject: [PATCH] Make separate template for send and receive mode --- onionshare/web.py | 20 +++-- share/html/receive.html | 105 +++++++++++++++++++++++++++ share/html/{index.html => send.html} | 0 3 files changed, 120 insertions(+), 5 deletions(-) create mode 100644 share/html/receive.html rename share/html/{index.html => send.html} (100%) diff --git a/onionshare/web.py b/onionshare/web.py index 2814616d..7e488a86 100644 --- a/onionshare/web.py +++ b/onionshare/web.py @@ -147,7 +147,7 @@ class Web(object): # If download is allowed to continue, serve download page r = make_response(render_template_string( - open(common.get_resource_path('html/index.html')).read(), + open(common.get_resource_path('html/send.html')).read(), favicon_b64=self.favicon_b64, logo_b64=self.logo_b64, folder_b64=self.folder_b64, @@ -275,7 +275,17 @@ class Web(object): """ @self.app.route("/") def index(slug_candidate): - return "Receive Mode" + self.check_slug_candidate(slug_candidate) + + # If download is allowed to continue, serve download page + r = make_response(render_template_string( + open(common.get_resource_path('html/receive.html')).read(), + favicon_b64=self.favicon_b64, + logo_b64=self.logo_b64, + slug=self.slug)) + for header, value in self.security_headers: + r.headers.set(header, value) + return r def common_routes(self): @@ -293,7 +303,7 @@ class Web(object): self.error404_count += 1 if self.error404_count == 20: self.add_request(self.REQUEST_RATE_LIMIT, request.path) - force_shutdown() + self.force_shutdown() print(strings._('error_rate_limit')) r = make_response(render_template_string( @@ -309,8 +319,8 @@ class Web(object): """ Stop the flask web server, from the context of an http request. """ - check_slug_candidate(slug_candidate, shutdown_slug) - force_shutdown() + self.check_slug_candidate(slug_candidate, shutdown_slug) + self.force_shutdown() return "" def set_file_info(self, filenames, processed_size_callback=None): diff --git a/share/html/receive.html b/share/html/receive.html new file mode 100644 index 00000000..942ec62e --- /dev/null +++ b/share/html/receive.html @@ -0,0 +1,105 @@ + + + + OnionShare + + + + + +
+ +

OnionShare

+
+ + + diff --git a/share/html/index.html b/share/html/send.html similarity index 100% rename from share/html/index.html rename to share/html/send.html