1

Could anyone point to roughly where in the python sdk code static routes get loaded into or accessed by http_server. This is to debug a failure to load static images. In eclipse I can see the static routes loading into var appinfo from the yaml file, and later can see the dynamic routes being checked during a request, but having trouble following the in-between steps. Thanks

Update 11/30

Previously tried variations on the yaml, path, etc that were suggested in some docs and postings. Here is one of them. In this case there is no 404 error, but image doesn't load and Firebug reports "Failed to the load the given URL".

app.yaml

application: crazywidget2  
version: 1  
runtime: python27  
api_version: 1  
threadsafe: false  

handlers:  
- url: /images  
  static_dir: /images  
  secure: always  

-url: /.*  
  script: crazywidget2.py  
  secure: always  

libraries:  
- name: jinja2    
  version: latest

index.html

...  
<img src="/images/xyz.gif" alt="XYZ illustration" />  
...  

crazywidget2.py

...
class MainPage(webapp2.RequestHandler):

    def get(self):
        template = jinja_environment.get_template('index.html')
        self.response.out.write(template.render({}))

...
...

app = webapp2.WSGIApplication([('/script_send', ScriptSend),
                        ('/resetkey', ResetKey),
                        ('/admin', Admin),  
                        ('/start', Start),  
                        ('/', MainPage)],  
                            debug=True)  


 def main():

    app.run()

if __name__=='__main__':
    main()                    

Update 12/3

Turns out that in the above case it works if the static_dir is relative, "images" instead of "/images". In the absolute case it tries to open that path as is. Maybe some other variations would work as well.

4

2 回答 2

0

以下是三个相关的代码指针(都在google/appengine/tools/dev_appserver.py中):

我会假设,有更简单的方法来调试你的问题。如果你发布你的 app.yaml 以及你访问的路径和你得到的响应,这里的人可以开始帮助你。

于 2012-11-30T09:03:04.687 回答
0

只是一个预感:如果您/images在处理程序的末尾添加一个斜杠,它会起作用吗?尝试在您使用它的两个地方/images替换为./images/app.yaml

于 2012-12-02T23:03:46.610 回答