【发布时间】:2026-02-03 12:15:02
【问题描述】:
我在 Google App Engine 上有一个静态 html 网站。唯一的流量是我自己访问该网站进行测试。我注意到它很快消耗了 Frontend Instance Hours。是否可以让它不创建任何实例,以便不消耗前端实例时间?谢谢!
我的文件结构是这样的: 我的根文件夹中有我的 index.html 文件、其他几个 html 文件和一个 pdf 文档。图像文件位于根目录内的 IMAGE 文件夹中。 css 位于根目录内的 FILES 文件夹中。 FILES 文件夹还有一个主题文件夹,其中包含图像和 css 文件。
我的完整 app.yaml 如下所示:
应用程序:myappname
版本:1
运行时:python
api_version: 1
处理程序:
-url: /(.*.(gif|png|jpg|ico|js|css|pdf))
静态文件:\1
上传:(.*.(gif|png|jpg|ico|js|css|pdf))
-网址:.*
脚本:main.py
main.py 文件如下所示:
导入操作系统
从 google.appengine.ext 导入 webapp
从 google.appengine.ext.webapp 导入实用程序
从 google.appengine.ext.webapp 导入模板
类 MainHandler(webapp.RequestHandler):
def get (self, q):
如果 q 为无:
q = 'index.html'
path = os.path.join (os.path.dirname (__file__), q)
self.response.headers ['Content-Type'] = 'text/html'
self.response.out.write (template.render (path, {}))
def main():
application = webapp.WSGIApplication ([('/(.*html)?', MainHandler)], debug=True)
util.run_wsgi_app(应用程序)
如果 __ name __ == '__ main __':
主()
没有 main.py 文件的 App.yaml 文件,成功了!!!!!! (-和url之间有一个空格)
应用程序:myappname
版本:1
运行时:python
api_version: 1
default_expiration: "7d"
处理程序:
-url: /(.*.(gif|png|jpg|ico|js|css|pdf|html))
静态文件:\1
上传:(.*.(gif|png|jpg|ico|js|css|pdf|html))
-网址:/
静态文件:index.html
上传:index.html
【问题讨论】: