skip to Main Content

i can only see the background image when accessing the HTML file directly but not when accessing it through the localhost server (i’m using Flask as framework)

This is the code of the background part:

  <style>
    body {
      background-image: url(file:///C:/Users/LENOVO/Desktop/chatbot-in-python-master/network.jpg);
      background-repeat: no-repeat;
      background-size: cover;
    }
  </style>

3

Answers


  1. Chosen as BEST ANSWER

    Nevermind it's because the local file system path and not a web server URL.However, recommend for me the best website to get the url without losing the quality of the image.


  2. The addressing method is not correct!
    First, try copying the image to the source folder (for convenience).
    Or address using dots and slashes

    Example:

    background-image: url(./images/network.jpg);
    

    or similar examples
    you can not use of local file system path!

    Login or Signup to reply.
  3. You can’t access the resource using that type of path since is a file system path.
    You could upload images to imgur and generate a short link to the image without losing the quality of the image.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search