Search code examples
web2py

More static files outside web2py directory


I would like to know is it possible to move static files outside the web2py directory and still reference with URL('static', 'images/some_pic.png'), similar to Django STATIC_ROOT.


Solution

  • If you want to let web2py serve static files, I believe they must be in the application's "static" folder. However, in production, it is recommended that you configure the web server to serve static files directly (see Nginx example). In that case, you can of course still use the URL() function to generate URLs for static files.

    Another option is to create symlinks in the "static" folder pointing to the files.