support vhosts in static routes
This commit is contained in:
@@ -354,13 +354,13 @@ class Sanic:
|
||||
# Static Files
|
||||
def static(self, uri, file_or_directory, pattern=r'/?.+',
|
||||
use_modified_since=True, use_content_range=False,
|
||||
stream_large_files=False, name='static'):
|
||||
stream_large_files=False, name='static', host=None):
|
||||
"""Register a root to serve files from. The input can either be a
|
||||
file or a directory. See
|
||||
"""
|
||||
static_register(self, uri, file_or_directory, pattern,
|
||||
use_modified_since, use_content_range,
|
||||
stream_large_files, name)
|
||||
stream_large_files, name, host)
|
||||
|
||||
def blueprint(self, blueprint, **options):
|
||||
"""Register a blueprint on the application.
|
||||
|
||||
@@ -18,7 +18,7 @@ from sanic.response import file, file_stream, HTTPResponse
|
||||
|
||||
def register(app, uri, file_or_directory, pattern,
|
||||
use_modified_since, use_content_range,
|
||||
stream_large_files, name='static'):
|
||||
stream_large_files, name='static', host=None):
|
||||
# TODO: Though sanic is not a file server, I feel like we should at least
|
||||
# make a good effort here. Modified-since is nice, but we could
|
||||
# also look into etags, expires, and caching
|
||||
@@ -122,4 +122,4 @@ def register(app, uri, file_or_directory, pattern,
|
||||
if not name.startswith('_static_'):
|
||||
name = '_static_{}'.format(name)
|
||||
|
||||
app.route(uri, methods=['GET', 'HEAD'], name=name)(_handler)
|
||||
app.route(uri, methods=['GET', 'HEAD'], name=name, host=host)(_handler)
|
||||
|
||||
Reference in New Issue
Block a user