summaryrefslogtreecommitdiff
path: root/onionshare
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2019-09-01 16:03:57 -0700
committerMicah Lee <micah@micahflee.com>2019-09-01 16:03:57 -0700
commite7959f9ae655d47133be7162cbb51209dead0744 (patch)
tree1f3b4cee9fda1992a152dc3b36c3a83da8cfe8b3 /onionshare
parenta0759cedcd085d150d70a111629e4940f76e4f85 (diff)
downloadonionshare-e7959f9ae655d47133be7162cbb51209dead0744.tar.gz
onionshare-e7959f9ae655d47133be7162cbb51209dead0744.zip
Add Web.generate_static_url_path back, so each share has its own static path
Diffstat (limited to 'onionshare')
-rw-r--r--onionshare/web/web.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/onionshare/web/web.py b/onionshare/web/web.py
index 17dd8c15..8d5a6af5 100644
--- a/onionshare/web/web.py
+++ b/onionshare/web/web.py
@@ -30,7 +30,7 @@ except:
pass
-class Web(object):
+class Web:
"""
The Web object is the OnionShare web server, powered by flask
"""
@@ -51,16 +51,12 @@ class Web(object):
self.common = common
self.common.log('Web', '__init__', 'is_gui={}, mode={}'.format(is_gui, mode))
- # The static URL path has a 128-bit random number in it to avoid having name
- # collisions with files that might be getting shared
- self.static_url_path = '/static_{}'.format(self.common.random_string(16))
-
# The flask app
self.app = Flask(__name__,
- static_url_path=self.static_url_path,
static_folder=self.common.get_resource_path('static'),
template_folder=self.common.get_resource_path('templates'))
self.app.secret_key = self.common.random_string(8)
+ self.generate_static_url_path()
self.auth = HTTPBasicAuth()
self.auth.error_handler(self.error401)
@@ -127,6 +123,17 @@ class Web(object):
elif self.mode == 'share':
self.share_mode = ShareModeWeb(self.common, self)
+ def generate_static_url_path(self):
+ # The static URL path has a 128-bit random number in it to avoid having name
+ # collisions with files that might be getting shared
+ self.static_url_path = '/static_{}'.format(self.common.random_string(16))
+ self.common.log('Web', 'generate_static_url_path', 'new static_url_path is {}'.format(self.static_url_path))
+
+ # Update the flask route to handle the new static URL path
+ self.app.static_url_path = self.static_url_path
+ self.app.add_url_rule(
+ self.static_url_path + '/<path:filename>',
+ endpoint='static', view_func=self.app.send_static_file)
def define_common_routes(self):
"""