无法从Google App Engine项目中显示html中的嵌入式图像

用户名

我想在处理程序提供的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
哈努曼

您几乎完全app.yaml正确,在静态文件处理程序中,您会找到配置静态目录处理程序所需的所有信息,但这非常简单:

version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /images
  static_dir: images
- url: /.*
  script: helloworld.app

然后在html上,您需要写完整的路径,从root开始:

<img src="/images/c1.gif">

当然,这假设您在images旁边有一个文件夹app.yaml,并且其中包含上述文件。

请务必阅读链接的文档,因为您还需要注意其他细微差别(例如,静态目录是从实例外部的CDN提供服务的事实)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法在Google App Engine上部署Java项目

单个Google App Engine项目中的Java和Python

无法在Google App Engine上发送电子邮件

更新/替换Google文档中的嵌入式图像

无法启动Google App Engine PHP教程

Google App Engine中的Cron作业无法正常工作

无法识别Google App Engine上的document_root

Google App Engine ManagedSSL无法正常工作

无法在Google Apps脚本中向电子邮件添加嵌入式图像

Google App Engine标准无法找到/执行Gunicorn

NodeJ:无法从Google App Engine连接Google Cloud SQL

在Google App Engine项目中使用Firestore

无法从Google App Engine上的NestJS项目访问Google Cloud SQL上的Cant访问PostgreSQL

Google App Engine意外的“网站无法提供安全连接”错误

覆盖Google App Engine项目中的程序包库

在Eclipse中清理Google App Engine项目

Android Google App Engine教程无法正常工作

无法下载Google App Engine 1.9.1

无法在Google App Engine中运行Coursebuilder

无法在Google App Engine启动器中绑定端口

如何在Google App Engine python项目中安装InfluxDB?

无法在pycharm中克隆App Engine项目

Google App Engine:无法找到“每日预算增加”

无法获取要在Google网站上显示的Google App

在Google App Engine(Java)中发送带有嵌入式图像的电子邮件

Google App Engine:无法创建位置设置为EU的项目?

无法将 OctoberCMS 部署到 Google App Engine (Flex)

无法从外部访问 Google App Engine 实例

无法匹配 Google App Engine 和 VPC 网络之间的区域