mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-22 14:38:00 +00:00
register static route on run
This commit is contained in:
parent
6018af1e68
commit
2be96a8ca5
|
@ -71,14 +71,6 @@ class Application(web.Application):
|
||||||
for path, view in VIEWS:
|
for path, view in VIEWS:
|
||||||
self.router.add_view(path, view)
|
self.router.add_view(path, view)
|
||||||
|
|
||||||
if self['dev']:
|
|
||||||
static = StaticResource('/static', get_resource('frontend/static'))
|
|
||||||
|
|
||||||
else:
|
|
||||||
static = CachedStaticResource('/static', get_resource('frontend/static'))
|
|
||||||
|
|
||||||
self.router.register_resource(static)
|
|
||||||
|
|
||||||
setup_swagger(
|
setup_swagger(
|
||||||
self,
|
self,
|
||||||
ui_version = 3,
|
ui_version = 3,
|
||||||
|
@ -154,6 +146,16 @@ class Application(web.Application):
|
||||||
self['push_queue'].put((inbox, message, instance))
|
self['push_queue'].put((inbox, message, instance))
|
||||||
|
|
||||||
|
|
||||||
|
def register_static_routes(self) -> None:
|
||||||
|
if self['dev']:
|
||||||
|
static = StaticResource('/static', get_resource('frontend/static'))
|
||||||
|
|
||||||
|
else:
|
||||||
|
static = CachedStaticResource('/static', get_resource('frontend/static'))
|
||||||
|
|
||||||
|
self.router.register_resource(static)
|
||||||
|
|
||||||
|
|
||||||
def run(self) -> None:
|
def run(self) -> None:
|
||||||
if self["running"]:
|
if self["running"]:
|
||||||
return
|
return
|
||||||
|
@ -166,6 +168,8 @@ class Application(web.Application):
|
||||||
logging.error(f'A server is already running on {host}:{port}')
|
logging.error(f'A server is already running on {host}:{port}')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.register_static_routes()
|
||||||
|
|
||||||
logging.info(f'Starting webserver at {domain} ({host}:{port})')
|
logging.info(f'Starting webserver at {domain} ({host}:{port})')
|
||||||
asyncio.run(self.handle_run())
|
asyncio.run(self.handle_run())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue