File tree Expand file tree Collapse file tree 8 files changed +160
-0
lines changed Expand file tree Collapse file tree 8 files changed +160
-0
lines changed Original file line number Diff line number Diff line change @@ -42,3 +42,11 @@ Topics covered:
4242* Dependency injection
4343* Time ([ time] ( //golang.org/pkg/time/ ) )
4444
45+ ### [ appengine-hello] ( appengine-hello/ ) ([ godoc] ( //godoc.org/github.com/golang/example/appengine-hello ) )
46+
47+ goapp get github.com/golang/example/appengine-hello
48+
49+ A trivial "Hello, world" App Engine application intended to be used as the
50+ starting point for your own code.
51+
52+ _ Note_ : The ` goapp ` tool is part of the [ Google App Engine SDK for Go] ( https://cloud.google.com/appengine/downloads#Google_App_Engine_SDK_for_Go ) .
Original file line number Diff line number Diff line change 1+ This code is a starting point for your Google App Engine application in
2+ Go.
3+
4+ To run the application locally you need the install the [ Go Cloud
5+ SDK] ( https://cloud.google.com/sdk/ ) and execute the next command from
6+ the directory containing this file:
7+
8+ $ goapp serve app.yaml
9+
10+ To deploy the application you have to first create an App Engine project
11+ and use it as the application file in all the yaml files.
Original file line number Diff line number Diff line change 1+ // Copyright 2015 Google Inc.
2+ //
3+ // Licensed under the Apache License, Version 2.0 (the "License");
4+ // you may not use this file except in compliance with the License.
5+ // You may obtain a copy of the License at
6+ //
7+ // http://www.apache.org/licenses/LICENSE-2.0
8+ //
9+ // Unless required by applicable law or agreed to in writing, software
10+ // distributed under the License is distributed on an "AS IS" BASIS,
11+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ // See the License for the specific language governing permissions and
13+ // limitations under the License.
14+
15+ // Package hello is a simple App Engine application that replies to requests
16+ // on /hello with a welcoming message.
17+ package hello
18+
19+ import (
20+ "fmt"
21+ "net/http"
22+ )
23+
24+ // init is run before the application starts serving.
25+ func init () {
26+ // Handle all requests with path /hello with the helloHandler function.
27+ http .HandleFunc ("/hello" , helloHandler )
28+ }
29+
30+ func helloHandler (w http.ResponseWriter , r * http.Request ) {
31+ fmt .Fprintln (w , "Hello from the Go app" )
32+ }
Original file line number Diff line number Diff line change 1+ # Copyright 2015 Google Inc. All rights reserved.
2+ # Licensed under the Apache License, Version 2.0 (the "License");
3+ # you may not use this file except in compliance with the License.
4+ # You may obtain a copy of the License at
5+ # http:#www.apache.org/licenses/LICENSE-2.0
6+
7+ # Unless required by applicable law or agreed to writing, software distributed
8+ # under the License is distributed on a "AS IS" BASIS, WITHOUT WARRANTIES OR
9+ # CONDITIONS OF ANY KIND, either express or implied.
10+
11+ # See the License for the specific language governing permissions and
12+ # limitations under the License.
13+
14+ application : you-application-id
15+ version : 1
16+ runtime : go
17+ api_version : go1
18+
19+ handlers :
20+ - url : /hello
21+ script : _go_app
22+
23+ - url : /favicon.ico
24+ static_files : static/favicon.ico
25+ upload : static/favicon.ico
26+
27+ - url : /
28+ static_files : static/index.html
29+ upload : static/index.html
30+
31+ - url : /
32+ static_dir : static
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+
3+ <!--
4+ Copyright 2015 Google Inc.
5+
6+ Licensed under the Apache License, Version 2.0 (the "License");
7+ you may not use this file except in compliance with the License.
8+ You may obtain a copy of the License at
9+
10+ http://www.apache.org/licenses/LICENSE-2.0
11+
12+ Unless required by applicable law or agreed to in writing, software
13+ distributed under the License is distributed on an "AS IS" BASIS,
14+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+ See the License for the specific language governing permissions and
16+ limitations under the License.
17+ -->
18+
19+ < html >
20+
21+ < head >
22+ < title > Hello, world</ title >
23+ < link rel ="stylesheet " href ="/style.css ">
24+ < script src ="/script.js "> </ script >
25+ </ head >
26+
27+ < body >
28+ < h1 > Hello, world</ h1 >
29+
30+ < button onclick ="fetchMessage() "> Fetch Message</ button >
31+ < p id ="message "> Click on the button to fetch the message.</ p >
32+ </ body >
33+
34+ </ html >
Original file line number Diff line number Diff line change 1+ /*
2+ Copyright 2015 Google Inc.
3+
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
7+
8+ http://www.apache.org/licenses/LICENSE-2.0
9+
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+ */
16+
17+ "use strict" ;
18+
19+ function fetchMessage ( ) {
20+ var xmlHttp = new XMLHttpRequest ( ) ;
21+ xmlHttp . open ( "GET" , "/hello" , false ) ;
22+ xmlHttp . send ( null ) ;
23+ document . getElementById ( "message" ) . innerHTML = xmlHttp . responseText ;
24+ }
Original file line number Diff line number Diff line change 1+ /*
2+ Copyright 2015 Google Inc.
3+
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
7+
8+ http://www.apache.org/licenses/LICENSE-2.0
9+
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+ */
16+
17+ h1 {
18+ text-align : center;
19+ }
You can’t perform that action at this time.
0 commit comments