Skip to content
Myr

Static files are active in the WSGI app now, not just the server.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 08f1f0d · Browse files · 3 files+15 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+15 added−5 removed

  • tests:+10 added−0 removed
  • other:+5 added−5 removed

3 files+15 added−5 removed

added:tests/static/index.html+1 added
modified:tests/flask_tests.py+9 added
141 unmodified lines
142 pass143 with app.test_request_context():144 assert flask.url_for('hello', name='test x') == '/hello/test%20x'145146 def test_static_files(self):147 app = flask.Flask(__name__)148 rv = app.test_client().get('/static/index.html')149 assert rv.status_code == 200150 assert rv.data.strip() == '<h1>Hello World!</h1>'151 with app.test_request_context():152 assert flask.url_for('static', filename='index.html') \153 == '/static/index.html'154155156class Templating(unittest.TestCase):157158 def test_context_processing(self):159 app = flask.Flask(__name__)
29 unmodified lines
modified:flask.py+5 added-5 removed
14 unmodified lines
15from threading import local16from contextlib import contextmanager17from jinja2 import Environment, PackageLoader18from werkzeug import Request as RequestBase, Response as ResponseBase, \19 LocalStack, LocalProxy, create_environ, cached_property19 LocalStack, LocalProxy, create_environ, cached_property, \20 SharedDataMiddleware21from werkzeug.routing import Map, Rule22from werkzeug.exceptions import HTTPException, InternalServerError23from werkzeug.contrib.securecookie import SecureCookie24
216 unmodified lines
241242 if self.static_path is not None:243 self.url_map.add(Rule(self.static_path + '/<filename>',244 build_only=True, endpoint='static'))245 self.wsgi_app = SharedDataMiddleware(self.wsgi_app, {246 self.static_path: (self.package_name, 'static')247 })248249 #: the Jinja2 environment. It is created from the250 #: :attr:`jinja_options` and the loader that is returned251 #: by the :meth:`create_jinja_loader` function.
37 unmodified lines
289 """290 from werkzeug import run_simple291 if 'debug' in options:292 self.debug = options.pop('debug')289 if self.static_path is not None:290 options['static_files'] = {291 self.static_path: (self.package_name, 'static')292 }293 options.setdefault('use_reloader', self.debug)294 options.setdefault('use_debugger', self.debug)295 return run_simple(host, port, self, **options)296
333 unmodified lines