Apra Barua
Apra Barua

Reputation: 159

HTML Website on Google App Engine

I have a static html website on Google App Engine. The only traffic is myself visiting the website to test. I notice that it consumes Frontend Instance Hours very quickly. Is it possible to make it not create any instance so that frontend instance hours are not consumed? Thanks!

My File structure is like this: I have my index.html file, few other html files and a pdf document in my root folder. The image files are in IMAGE folder inside root directory. A css is inside FILES folder inside root directory. The FILES folder also has a THEME folder which has images and a css file.

My full app.yaml looks like this:

application: myappname
version: 1
runtime: python
api_version: 1

handlers:
-url: /(.*.(gif|png|jpg|ico|js|css|pdf))
static_files: \1
upload: (.*.(gif|png|jpg|ico|js|css|pdf))

-url: .*
script: main.py

The main.py file looks like this:

import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template

class MainHandler(webapp.RequestHandler):
def get (self, q):
if q is None:
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 (application)

if __ name __ == '__ main __':
main ()

The App.yaml file without the main.py file, that worked!!!!! (there is a space between - and url)

application: myappname
version: 1
runtime: python
api_version: 1

default_expiration: "7d"

handlers:
-url: /(.*.(gif|png|jpg|ico|js|css|pdf|html))
static_files: \1
upload: (.*.(gif|png|jpg|ico|js|css|pdf|html))

-url: /
static_files: index.html
upload: index.html

Upvotes: 1

Views: 3298

Answers (1)

aschmid00
aschmid00

Reputation: 7158

you could upload the files as static files so it would only consume outgoing bandwith but no instances.
https://developers.google.com/appengine/docs/python/config/appconfig#Static_File_Pattern_Handlers

Upvotes: 4

Related Questions