Hi im new to the raspberry pi and i am hosting a simple webpage on the pi model A using web.py. Its all working fine but i cannot get an image to show up. Everytime i go to the website i get this error - "HTTP/1.1 GET /rpi.png" - 404 Not Found

the image tag i am using is <img src="rpi.png" alt="Logo" width="100" height="150">

I have also tried <img src="http://rpi ip address:8080/path/to/rpi.png" alt="Logo">

All other parts of the website work correctly so i presume it is to do with the img tag? Also the image is saved in the template folder with the html file.

Any help is appreciated.thanks very much

Edit: app.py code

<!-- language: lang-python -->

    import web

    render = web.template.render('/home/pi/projects/web_led/templates/')

    urls = (
        '/', 'index', 'static'

    status = 0

    class Index():
            def GET(self):
                    return render.hello_form(0)

            def POST(self):
                    form = web.input()
                    global status
                    led = int(form.foo)
                    status = status + led
                    return render.hello_form(status = status)
                    #add gpio code here

    if __name__ == "__main__":
        app = web.application(urls, globals())

ls -ls in app.py folder:

pi@raspberrypi ~/projects/web_led/bin $ ls -la
total 24
drwxr-xr-x 3 pi   pi   4096 Dec 22 22:52 .
drwxr-xr-x 4 pi   pi   4096 Dec 22 14:13 ..
-rw-r--r-- 1 root root  597 Dec 22 23:50 app.py
-rw-r--r-- 1 root root 1066 Dec 22 22:52 app.pyc
-rw-r--r-- 1 root root  392 Dec 22 01:05 app.py.save
drwxr-xr-x 2 pi   pi   4096 Dec 22 23:45 static

ls -la in static folder:

pi@raspberrypi ~/projects/web_led/bin/static $ ls -la
total 96
drwxr-xr-x 2 pi pi  4096 Dec 22 23:45 .
drwxr-xr-x 3 pi pi  4096 Dec 22 22:52 ..
-rwxrwxrwx 1 pi pi 89681 Dec 22 15:28 rpi.png

HTML file referencing image(Everything but the image works and responds properly):

$def with (status)


                <title>LED TEST</title>


<h1>Home Automation</h1>

<img src="projects/web_led/bin/static/rpi.png" alt="Logo">

<form action="/" method="POST">
        Pick a LED:
        $if status == 0 or status == 2 or status == 4 or status == 6:
                <button name="foo" value="1">Turn Red Led ON</button>
                <button name="foo" value="-1">Turn Red Led OFF</button>
        $if status == 0 or status == 1 or status == 4 or status == 5:
                <button name="foo" value="2">Turn Blue Led ON</button>
                <button name="foo" value="-2">Turn Blue Led OFF</button>
        $if status == 0 or status == 1 or status ==2 or status == 3:
                <button name="foo" value="4">Turn Green Led ON</button>
                <button name="foo" value="-4">Turn Green Led OFF</button>


Current error

###.###.###.###:##### - - [23/Dec/2015 14:08:36] "HTTP/1.1 GET /projects/web_led/bin/static/rpi.png" - 500 Internal Server Error
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 239, in process
    return self.handle()
  File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 229, in handle
    fn, args = self._match(self.mapping, web.ctx.path)
  File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 427, in _match
    for pat, what in mapping:
ValueError: need more than 1 value to unpack

###.###.###.###:####0 - - [23/Dec/2015 14:08:36] "HTTP/1.1 GET /favicon.ico" - 500 Internal Server Error

closed as off-topic by goldilocks Dec 29 '15 at 19:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be specific to the Raspberry Pi within the scope defined in the help center." – goldilocks
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Welcome to RPi.SE. Can you tell us which frame work are you using to host web page ? Also, edit your question to include your code of web.py. – dhruvvyas90 Dec 22 '15 at 16:18
  • 2
    What is the path to the file? Is it in the same directory as the webpage? what are the permissions and ownership of the image? – Steve Robillard Dec 22 '15 at 16:18
  • Do you have a handler for static files setup? webpy.org/cookbook/staticfiles – Steve Robillard Dec 22 '15 at 16:26
  • @dastaan my framework is just web.py and I have edited the question now. – piguy Dec 22 '15 at 17:11
  • @SteveRobillard I created the static folder and placed the image in there. do i need to create a class like class static: in my app.py file? Thanks for the answer both of you guys – piguy Dec 22 '15 at 17:44

You're not telling your web framework that there's images to serve. The only url you've specified is the Index page at /. Take a look at web.py's image documentation.

  • I added the folder to urls and i no longer get a 404 not found error. I now get "HTTP/1.1 GET /bin/static/rpi.png - 500 Internal Server Error. Any ideas where to go from here? – piguy Dec 22 '15 at 17:41
  • @piguy: Something in your script is erroring. I would start by figure out how web.py logs things (or add logs if it doesn't by default) and go from there. – Jacobm001 Dec 22 '15 at 17:48
  • @piguy you will need to add the updated app.py if we are to help further. Also, can you include the ls -la output for both the static directory and the directory where app.py is located. – Steve Robillard Dec 23 '15 at 10:30
  • @SteveRobillard i have edited the question as you asked. I also added the current error to the question – piguy Dec 23 '15 at 14:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.