Reverse static arguments
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from .sanic import Sanic
|
||||
from .blueprints import Blueprint
|
||||
|
||||
__version__ = '0.1.6'
|
||||
__version__ = '0.1.7'
|
||||
|
||||
__all__ = ['Sanic', 'Blueprint']
|
||||
|
||||
@@ -33,14 +33,14 @@ class BlueprintSetup:
|
||||
"""
|
||||
self.app.exception(*args, **kwargs)(handler)
|
||||
|
||||
def add_static(self, file_or_directory, uri, *args, **kwargs):
|
||||
def add_static(self, uri, file_or_directory, *args, **kwargs):
|
||||
"""
|
||||
Registers static files to sanic
|
||||
"""
|
||||
if self.url_prefix:
|
||||
uri = self.url_prefix + uri
|
||||
|
||||
self.app.static(file_or_directory, uri, *args, **kwargs)
|
||||
self.app.static(uri, file_or_directory, *args, **kwargs)
|
||||
|
||||
def add_middleware(self, middleware, *args, **kwargs):
|
||||
"""
|
||||
@@ -122,8 +122,8 @@ class Blueprint:
|
||||
return handler
|
||||
return decorator
|
||||
|
||||
def static(self, file_or_directory, uri, *args, **kwargs):
|
||||
def static(self, uri, file_or_directory, *args, **kwargs):
|
||||
"""
|
||||
"""
|
||||
self.record(
|
||||
lambda s: s.add_static(file_or_directory, uri, *args, **kwargs))
|
||||
lambda s: s.add_static(uri, file_or_directory, *args, **kwargs))
|
||||
|
||||
@@ -95,13 +95,13 @@ class Sanic:
|
||||
return register_middleware
|
||||
|
||||
# Static Files
|
||||
def static(self, file_or_directory, uri, pattern='.+',
|
||||
def static(self, uri, file_or_directory, pattern='.+',
|
||||
use_modified_since=True):
|
||||
"""
|
||||
Registers a root to serve files from. The input can either be a file
|
||||
or a directory. See
|
||||
"""
|
||||
static_register(self, file_or_directory, uri, pattern,
|
||||
static_register(self, uri, file_or_directory, pattern,
|
||||
use_modified_since)
|
||||
|
||||
def blueprint(self, blueprint, **options):
|
||||
|
||||
@@ -7,7 +7,7 @@ from .exceptions import FileNotFound, InvalidUsage
|
||||
from .response import file, HTTPResponse
|
||||
|
||||
|
||||
def register(app, file_or_directory, uri, pattern, use_modified_since):
|
||||
def register(app, uri, file_or_directory, pattern, use_modified_since):
|
||||
# TODO: Though sanic is not a file server, I feel like we should atleast
|
||||
# make a good effort here. Modified-since is nice, but we could
|
||||
# also look into etags, expires, and caching
|
||||
|
||||
Reference in New Issue
Block a user