0

I want to add /static/ in front of all the paths in index.html. Since Flask looks for static files inside the /root_folder/static folder. Even though I have placed all the files inside the static folder, it is unable to get the files as the path in the index.html file is not correct.

My current directory structure in Flask looks like this

web_ui
    src
       -static
       -web_app.py
    logs
    config

This is what the path to various files in index.html looks like.

  <script src="assets/js/apexcharts.min.js"></script>
  <script src="assets/js/bootstrap.bundle.min.js"></script>

I would like to have

  <script src="/static/assets/js/apexcharts.min.js"></script>
  <script src="/static/assets/js/bootstrap.bundle.min.js"></script>

is there any way to change the angular.json file? I have changed the output directory

"architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "../web_ui/src/static/",  #<----
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/custom-theme.scss",
              "src/styles.css"
            ],
            "scripts": [
              "src/assets/js/main.js",
              "node_modules/apexcharts/dist/apexcharts.min.js"
            ]

I have looked into this answer but the person has not explained how to do it. Do I have to manually change the path?

1 Answer 1

-1

Not sure if there's an Angular way to do this, but there is a Flask way to change the directory where static files are loaded. See this.

app = Flask(__name__, static_folder="")  # Not "static"
Sign up to request clarification or add additional context in comments.

1 Comment

this will not work with angular as index.html is dynamically generated during the build process and you are not supposed to manually edit it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.