Unable to see image on Google app engine web

非 Y 不嫁゛ 提交于 2019-12-24 12:53:01

问题


I Just want to show image on Google app Engine Website. I am new to Google app engine. I made changes in App.yaml and Main.py app.yaml looks like :

application: simplegraph-007
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /favicon\.ico
 static_files: favicon.ico
 upload: favicon\.ico

- url: /images
 static_dir: static/images
 mime_type: image/png

- url: .*
  script: main.app

 libraries:
 - name: webapp2
  version: "2.5.2"

Main.py looks like.

import webapp2

class MainHandler(webapp2.RequestHandler):
def get(self):
    self.response.out.write("""<img src = 'D:\download\rel.png/>""")

app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)

What else I need to change. I hope to get help.

Thanks,


回答1:


Copy the image to static/images directory in your project. From a browser, this path is "/images".

If you just want to show the image, in your browser, go to: http://localhost:8080/images/rel.png

To see the image from the cloud, deploy your app and see the image at: http://PROJECT_ID.appspot.com/images/rel.png

To use that image within an html page, use:

<img src="/images/rel.png" />



回答2:


You are outputting invalid HTML. It is missing the closing single quote ' and has an extra trailing /.

<img src = 'D:\download\rel.png/>

Also you are trying to serve an image directly from your filesystem which may work locally, but it will not work when deployed to app engine.



来源:https://stackoverflow.com/questions/33175530/unable-to-see-image-on-google-app-engine-web

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!