0

I can get it to work on windows but I can not get it work on Ubuntu server. The file is in the images folder and inside that is the png file. The html is in the templates folder and inside the template folder is the images folder with the png file. I have the same setup on windows and it works.

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Search</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    
<div class= "container">
    <form action="/search" class="search-bar" method="GET">
        <label for="query">Search:</label><br>
        <input type="text" name="query" placeholder="Enter Serial Number"><br>
        <button type="submit"><img src="images/search.png"></button>
    </form>
</div>
    
</body>
</html>

I try move the files and even copy the whole dir the issue persist. It suppose to show an image but it don't. Even my style.css not being found.

Mario242
  • 1
  • 2
  • Could it be a permissions issue? What is the devtools showing? What server are you using? Can we see its config? Root folder? Folder structure? – Yarin_007 Dec 23 '22 at 17:33
  • @Yarin_007 sorry its a: Distributor ID: Ubuntu Description: Ubuntu 22.04.1 LTS Release: 22.04 Codename: jammy – Mario242 Dec 23 '22 at 17:39
  • I meant what web server? what "templates folder"? – Yarin_007 Dec 23 '22 at 17:39
  • @Yarin_007 root@lab:/home/lab/Flask/template/images# ls search.png – Mario242 Dec 23 '22 at 17:40
  • @Yarin_007 Im using flask – Mario242 Dec 23 '22 at 17:41
  • Okay, cool. Hit f12 in the browser then refresh the website. does the network tab say anything? what happnes when you go directly to the style.css? could it be that the files need to be in the [default "static" route](https://stackoverflow.com/a/20648053/4935162)? Can you attach your python code? – Yarin_007 Dec 23 '22 at 17:42
  • @Yarin_007 the network tab shows 404 NOT FOUND for both the png file and the stlye.css, still checking – Mario242 Dec 23 '22 at 17:47
  • Okay when I go directly to the style.css it just goes to : Not Found The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again. – Mario242 Dec 23 '22 at 17:50
  • https://github.com/Mario242619/App you can view it from here – Mario242 Dec 23 '22 at 17:54
  • @Yarin_007 If it was to be a permission issue would you able to tell me how to change the permission? – Mario242 Dec 23 '22 at 18:01
  • yes, it's simply (probably) running chmod 644 . but it's likely not a permissions issue. could you try [this](https://stackoverflow.com/a/55936758/4935162)? simply creating a static folder and move the files there. ['url for'](https://stackoverflow.com/a/16353060/4935162) could help as well – Yarin_007 Dec 23 '22 at 18:22
  • @Yarin_007 i got it to work with a static folder. – Mario242 Dec 23 '22 at 19:00
  • Cool, happy to hear. Very strange it worked on windows. By the way, you should check out [using nginx to server static files](https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-22-04), as it is much better at this than flask. But if your application is small (doesn't experience load), you're probably fine. – Yarin_007 Dec 23 '22 at 22:50

0 Answers0