0

In my views, the code of my index.html is:

    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
        <strong><h1>FlowTow</h1></strong>
        <b><h3>POWERED BY BOOTSTRAP</h3></b>
    </div>

    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
        % for item in result:
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 image">

            <p class="username">{{item['user']}}</p>
            <p class="dates">{{item['timestamp']}}</p>
            <div class="clearfix"></div>
            <img src="static/images/{{item['filename']}}" alt="{{item['filename']}}" class="img-responsive imagee">

            <p class="likes">{{ item['likes'] }}Likes</p>

            <form action="/like" method="post" class="like_form">
                <input type="hidden" name="filename" value="{{item['filename']}}">
                <input type="submit" class="btn btn-success" value="Like">
            </form>
            <div class="clearfix"></div>
        </div>
        % end

    </div>

</div>

But the index does not show the image. The image is stored in my file "static/images". When I check the element of the website, the address of the image is shown like:

<img src="static/images/cycling.jpg" alt="cycling.jpg" class="img-responsive imagee">

I am sure the url of the image is correct. Can someone tell me why the image is not shown?

Cyrbil
  • 6,341
  • 1
  • 24
  • 40
DataJ
  • 153
  • 1
  • 1
  • 7

1 Answers1

1

The documentation shows how to serve static file:
Simply create a route for it in your app and use static_file() function

from bottle import static_file
@route('/static/<filepath:path>')
def server_static(filepath):
    return static_file(filepath, root='/path/to/your/static/files')
Cyrbil
  • 6,341
  • 1
  • 24
  • 40