why even after adding the -url: /images in app.yaml, i can't access /images/med-9.png ,
Question: I am learning python, specifically web development using python, and am
following the course cs253 in udacity, now after performing the unit 4
excercise, i want to add an image in my html template, i have made a directory
: "Templates" in my "hellowebappworld" directory which is the directory being
hosted by app engine and inside templates, i've made a folder : "images" where
i have my image. even after adding the url : / images and static_dir: images m
not able to access the image

this is my app.yaml:

    
    
    application: hellowebappworld
    version: 1
    runtime: python27
    api_version: 1
    threadsafe: yes
    
    handlers:
    - url: /favicon\.ico
      static_files: favicon.ico
      upload: favicon\.ico
    
    - url: /images
      static_dir: images 
    
    - url: .*
      script: main.py
    
    libraries:
    - name: webapp2
      version: latest
    - name: jinja2
      version: latest
    

following is the main.py:

    
    
    import os
    import webapp2
    import jinja2
    from google.appengine.ext import db
    
    template_dir = os.path.join(os.path.dirname(__file__), 'templates')
    jinja_env = jinja2.Environment(loader =            jinja2.FileSystemLoader(template_dir), autoescape=True)
    
    class Art(db.Model):
        title = db.StringProperty(required = True)
        art = db.TextProperty(required = True)
        created = db.DateTimeProperty(auto_now_add = True)
    
    
    
    class Handler(webapp2.RequestHandler):
        def write(self, *a, **kw):
            self.response.out.write(*a, **kw)
        def render_str(self, template, **params):
            t = jinja_env.get_template(template)
            return t.render(params)
        def render(self, template, **kw):
            self.write(self.render_str(template, **kw))
    
    class MainPage(Handler):
        def render_front(self, title="", art="", error=""):
            arts = db.GqlQuery("SELECT * FROM Art ORDER BY created DESC")
            self.render("front.html", title=title, art=art, error = error, arts     = arts)
        def get(self):
            self.render_front()
        def post(self):
            title = self.request.get("title")
            art = self.request.get("art")
            if title and art:
                a = Art(title = title, art = art)
                a.put()
                self.redirect("/")
            else:
                error = "we need both a title and some artwork!"
                self.render_front(title,art,error)
    
    app = webapp2.WSGIApplication([('/', MainPage)], debug=True)
    

and finally my template:

    
    
    <!DOCTYPE html>
    
    <html>
        <head>
            <title>/ascii/</title>
    
        </head>
        <body>
    <form method="post">
        <label>
            <div>title</div><input type="text" name="title" value= {{title}}>
        </label>
        <label>
            <div>art</div><textarea name="art"> {{art}} </textarea>
        </label>
        <div class="error"> {{error}}</div>
        <input type="submit">
    </form>
    <hr>
        {% for art in arts %}
        <div class="art">
            <div class="art-title">{{art.title}}</div>
            <pre class="art-body">{{art.art}}</pre>
        </div>
        {% endfor %}
        <img src="/images/med-9.png">
        </body>
    


Answer: try modifying your app.yaml file to this..

    
    
    - url: /templates/images
      static_dir: templates/images 
    

On a side note, I like to structure my static files like so..

    
    
    - url: /static
      static_dir: static
    

then my static folder is located in the root directory of my app engine app.

  * Desktop 
    * ProjectFolder 
      * static 
        * images
        * js
        * css
      * templates
      * main.py
      * app.yaml

