Skip to content

Extension and static folder #284

Answered by gi0baro
josejachuf asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @josejachuf, it's not possible to have a separated static source, thus you have 2 options:

  • copying your static files to the application static folder in your extension on_load method
  • add a route within your module to serve those static files from the correct location

The 2nd option would be something like this:

from emmett import response
from emmett.http import HTTPFile

def stream_route():
    full_path = "something/in/your/module.js"
    raise HTTPFile(
        full_path,
        headers=response.headers,
        cookies=response.cookies
    )

then in your on_load bind the route:

def on_load(self):
    self.app.route("/someurl")(stream_route)

you can probably get the paths dynamic…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gi0baro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #284 on December 11, 2020 16:16.