How to host static HTML files on Google App Engine?

吃可爱长大的小学妹 提交于 2019-12-18 09:59:30

问题


Is it possible to host a static HTML website on App Engine? And how to make my domain name work with it?


回答1:


I wrote a library to do just that, and it works on AppEngine or any other server you want:

https://github.com/stochastic-technologies/static-appengine-hoster

You just throw your files in the directory, and it hosts them. It also supports Jinja2 templates, URL rewriting and multiple domains.




回答2:


Yes you can host your static files on AppEngine. Just configure your app.yaml-file like the following

- url: /
  static_dir: static_files

And put your files in the directory static_files. This way every request is routed to your static files.




回答3:


I just had the same problem and decided to use this solution... It serves static files from the root directory and uses index.html if you don't give an file. Hope that helps.

# re-direct to index.html if no path is give
- url: /
  static_files: index.html
  upload: index.html

# access the static resources in the root director

- url: /(.*)
  static_files: \1
  upload: (.*)



回答4:


I've found what I believe is a really neat solution.

DryDrop

Basically, from what I'm led to believe, you deploy DryDrop to GAE, configure (domains, Github html repository etc.), then publish your static HTML by pushing to the GitHub repository (GitHub utilises 'hooks' to alert your DryDrop install to any new HTML changes).

I haven't used it personally, yet, but if the former CTO of Threadless Tees, Harper Reed, thinks it's OK, that's good enough for me :-D .

Cheers

Rich




回答5:


To use your own domain with Google App Engine first you have to set your domain to work with Google Apps.

You then link the relevant Google App Engine application to the Google Apps Domain.




回答6:


This also worked for me. It's exactly like @BradAbrams solution only with static_dir for the second part :

handlers:

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

- url: /*
  static_dir: "."



回答7:


You don't need to make use of any other scripts per say to host a static website. I just had to do similar things that you have mentioned.

  1. A custom domain addition
  2. Hosting Mostly HTML and Static content
  3. A few php scripts (Not required for you)

Define Handlers for every static .html file like this

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

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

For Static Directories use this

- url: /images
  static_dir: images

Making Use of Custom Domain

If you have purchased domain from somewhere else then you'll have to add your domain as custom domain and then go on with verification process for your domain. In my case my domain provider was godaddy.com and google did the verification process automatically. Although I had to add the Cname records after that manually in godaddy domain's DNS section. Google has complete automated system in place for the same so that wont be difficult at all.



来源:https://stackoverflow.com/questions/819346/how-to-host-static-html-files-on-google-app-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!