如何在 Google App Engine 上托管静态 HTML 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/819346/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to host static HTML files on Google App Engine?
提问by zotherstupidguy
Is it possible to host a static HTML website on App Engine? And how to make my domain name work with it?
是否可以在 App Engine 上托管静态 HTML 网站?以及如何让我的域名使用它?
采纳答案by Stavros Korokithakis
I wrote a library to do just that, and it works on AppEngine or any other server you want:
我编写了一个库来做到这一点,它可以在 AppEngine 或您想要的任何其他服务器上运行:
https://github.com/stochastic-technologies/static-appengine-hoster
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.
您只需将文件放入目录中,它就会托管它们。它还支持 Jinja2 模板、URL 重写和多域。
回答by B.E.
Yes you can host your static files on AppEngine. Just configure your app.yaml-file like the following
是的,您可以在 AppEngine 上托管您的静态文件。只需像下面这样配置你的 app.yaml 文件
- url: /
static_dir: static_files
And put your files in the directory static_files. This way every request is routed to your static files.
并将您的文件放在目录 static_files 中。这样,每个请求都会路由到您的静态文件。
回答by Brad Abrams
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.
我刚刚遇到了同样的问题并决定使用这个解决方案......它从根目录提供静态文件,如果你不提供文件,则使用 index.html。希望有帮助。
# 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:
upload: (.*)
回答by Big Rich
I've found what I believe is a reallyneat 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).
基本上,根据我所相信的,您将 DryDrop 部署到 GAE,配置(域、Github html 存储库等),然后通过推送到 GitHub 存储库来发布您的静态 HTML(GitHub 利用“钩子”来提醒您的 DryDrop 安装任何新的 HTML 更改)。
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 .
我个人还没有使用过它,但是如果 Threadless T 的前 CTO Harper Reed 认为它可以,那对我来说已经足够了 :-D 。
Cheers
干杯
Rich
富有的
回答by Dave Webb
To use your own domain with Google App Engine first you have to set your domain to work with Google Apps.
要将您自己的域与 Google App Engine 一起使用,您必须首先将域设置为与 Google Apps 一起使用。
You then link the relevant Google App Engine application to the Google Apps Domain.
回答by ychaouche
This also worked for me. It's exactly like @BradAbrams solution only with static_dir for the second part :
这也对我有用。它与 @BradAbrams 解决方案完全一样,仅在第二部分使用 static_dir :
handlers:
- url: /
static_files: index.html
upload : index.html
- url: /*
static_dir: "."
回答by Gandalf the White
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.
您不需要使用任何其他脚本来托管静态网站。我只需要做你提到的类似事情。
- A custom domain addition
- Hosting Mostly HTML and Static content
- A few php scripts (Not required for you)
- 自定义域添加
- 主要托管 HTML 和静态内容
- 一些 php 脚本(你不需要)
Define Handlers for every static .html file like this
像这样为每个静态 .html 文件定义处理程序
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.
如果您从其他地方购买了域,那么您必须将您的域添加为自定义域,然后继续对您的域进行验证过程。就我而言,我的域名提供商是 Godaddy.com,谷歌自动完成了验证过程。虽然我必须在 godaddy 域的 DNS 部分手动添加 Cname 记录。谷歌有完整的自动化系统,所以这根本不困难。