0

I'm trying to do the following:

Having a file structure like the following:

/app
    /static
        /start
            /css
            /js
            - index.html
    /templates

Id like to know how I can serve this index.html and make this load its CSS and JS without using url_for('static', filename='') or other kind of serving trough Flask.

Basically, I want to put http://local.com/start and trough Flask serve index.html which will load its own css and js like <link href="css/style.css" rel="stylesheet">

I tried send_from_directory('/static/start', "index.html") and app.send_static_file('index.html') but they don't work.

I also tried current_app.send_static_file('start/index.html') but this only serves the html. It doesn't make the index.html load its own CSS and JS.

I got the information from these links

  • How to serve static files in Flask
  • python flask - serving static files
  • Flask: How to serve static html?
  • They don't do what I want (or maybe I'm doing it wrong).

    Thanks in advance, if there is more info needed just tell me.

    Community
    • 1
    • 1
    Aitor Martin
    • 724
    • 1
    • 11
    • 26

    1 Answers1

    0

    You can load a regular html file as a jinja template. Just call render without any parameters.