Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在google app engine中显示图像?_Python_Html_Image_Google App Engine - Fatal编程技术网

Python 如何在google app engine中显示图像?

Python 如何在google app engine中显示图像?,python,html,image,google-app-engine,Python,Html,Image,Google App Engine,这应该很容易,但我有麻烦 我的main.py如下所示: import webapp2 import urllib2 from google.appengine.api import images from google.appengine.ext import db class MainHandler(webapp2.RequestHandler): def get(self): self.response.write("hello worldd") #

这应该很容易,但我有麻烦

我的main.py如下所示:

import webapp2
import urllib2
from google.appengine.api import images
from google.appengine.ext import db

class MainHandler(webapp2.RequestHandler):
    def get(self):
        self.response.write("hello worldd")
        #********????*********
app = webapp2.WSGIApplication([
    ('/', MainHandler)
], debug=True)
application: myprojectnamehere
version: 1
runtime: python27
api_version: 1
threadsafe: yes

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

- url: .*
  script: main.app

- url: /images
  static_dir: images

libraries:
- name: webapp2
  version: "2.5.2"
在我评论过的地方,我可以放置一些html标题等吗?当我这样做的时候,它就断了

我的app.yaml如下所示:

import webapp2
import urllib2
from google.appengine.api import images
from google.appengine.ext import db

class MainHandler(webapp2.RequestHandler):
    def get(self):
        self.response.write("hello worldd")
        #********????*********
app = webapp2.WSGIApplication([
    ('/', MainHandler)
], debug=True)
application: myprojectnamehere
version: 1
runtime: python27
api_version: 1
threadsafe: yes

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

- url: .*
  script: main.app

- url: /images
  static_dir: images

libraries:
- name: webapp2
  version: "2.5.2"
我的图像存储在名为“images”的目录中,与main.py位于同一个项目文件夹中

当我点击“部署”时,是否自动将其上载到服务器

我在谷歌的网站上找到了一些线索,如,和,但我仍然有这个问题。你能帮我跟上进度吗?我想最终显示一个图像,这是一个自定义按钮,检测鼠标点击图像,并改变图像作为结果

任何指导都很好。我想做的应该很简单,但事实证明比我想象的要困难得多。从文档中的基本搜索中,我找到了一些线索,但似乎没有一条线索能够为我在应用程序引擎网页上显示简单图像所需要使用的东西指明一个明确的确切方向


接下来,根据我找到的线索,我将熟悉一种称为的方法。

两件事:您需要http头,是的,您可以将头放在响应中,在写入任何内容之前尝试将其放在响应中。还有:什么休息?你能给我们看一下回溯吗?同时阅读如何使用。我猜您现在看到的内容更多地与如何加载HTML页面有关。首先,您应该在app.yaml中交换-/图像和-.*。当一个请求传入时,它会自上而下地读取,直到找到匹配的内容将捕获所有内容,因此您将永远无法获取图像。我还建议您遵循以下步骤,因为它向您展示了如何设置标题以及如何使用模板。