【发布时间】:2015-09-10 03:16:44
【问题描述】:
我想在我的处理程序提供的 html 文件中的表单之前显示一些图像;我已经归结为下面最小的一段代码。
我的图像需要存储在哪里?我需要在app.yaml 中指定什么才能看到它们?目前它们没有显示,大概是因为 GAE 在其他位置查找它们(我将 gif 图像保存在根文件夹中)。
代码如下:
import webapp2
form="""
<img src="./c1.gif"><img src="./r1.gif">
<form action="/test">
<input name="q">
<input type="Submit">
</form>
"""
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/html'
self.response.write(form)
class TestHandler(webapp2.RequestHandler):
def get(self):
q = self.request.get("q")
self.response.headers['Content-Type'] = 'text/html'
self.response.write("Hello, still not working!")
app = webapp2.WSGIApplication([
('/', MainPage),
('/test', TestHandler)
], debug=True)
App.yaml:
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: helloworld.app
编辑:用我的 app.yaml 尝试了以下以及其他变体,但没有运气:
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /images/*.gif
static_dir: images
- url: /.*
script: helloworld.app
【问题讨论】:
标签: python html image google-app-engine