summaryrefslogtreecommitdiff
path: root/onionshare
diff options
context:
space:
mode:
authorhiro <hiro@torproject.org>2019-06-13 22:56:48 +0200
committerhiro <hiro@torproject.org>2019-06-13 22:56:48 +0200
commit66e85497efb023ab46eda9163bd2f667916bc134 (patch)
treedd686e35ab622f4e13e2d4835b0b69a3522032c3 /onionshare
parent4d733c224a320a7aa5d430d8440a50cb833cbc16 (diff)
downloadonionshare-66e85497efb023ab46eda9163bd2f667916bc134.tar.gz
onionshare-66e85497efb023ab46eda9163bd2f667916bc134.zip
Revert "Generate a new static_url_path each time the server is stopped and started again"
This change creates problems with how website mode renders assets. This reverts commit 50b2311409cd93814324a4570e8bdc5d032748c8.
Diffstat (limited to 'onionshare')
-rw-r--r--onionshare/web/web.py18
1 files changed, 5 insertions, 13 deletions
diff --git a/onionshare/web/web.py b/onionshare/web/web.py
index 1d2a3fec..17dd8c15 100644
--- a/onionshare/web/web.py
+++ b/onionshare/web/web.py
@@ -51,12 +51,16 @@ 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)
@@ -225,18 +229,6 @@ class Web(object):
self.password = self.common.build_password()
self.common.log('Web', 'generate_password', 'built random password: "{}"'.format(self.password))
- 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 verbose_mode(self):
"""
Turn on verbose mode, which will log flask errors to a file.