Last active
January 1, 2016 01:49
-
-
Save gertcuykens/8075116 to your computer and use it in GitHub Desktop.
go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
application: ... | |
version: 0 | |
runtime: go | |
api_version: go1 | |
threadsafe: true | |
handlers: | |
- url: /css | |
static_dir: home/css | |
- url: /img | |
static_dir: home/img | |
- url: /js | |
static_dir: home/js | |
- url: /fonts/(.*\.woff) | |
static_files: home/fonts/\1 | |
upload: home/fonts/(.*\.woff) | |
mime_type: font/woff | |
#http_headers: | |
# Content-Type: font/woff | |
#application/font-woff | |
- url: /fonts/(.*\.svg) | |
static_files: home/fonts/\1 | |
upload: home/fonts/(.*\.svg) | |
mime_type: image/svg+xml | |
#http_headers: | |
# Content-Type: image/svg+xml | |
- url: /fonts/(.*\.eot) | |
static_files: home/fonts/\1 | |
upload: home/fonts/(.*\.eot) | |
mime_type: application/vnd.ms-fontobject | |
#http_headers: | |
# Content-Type: application/vnd.ms-fontobject | |
- url: /fonts/(.*\.ttf) | |
static_files: home/fonts/\1 | |
upload: home/fonts/(.*\.ttf) | |
mime_type: application/x-font-ttf | |
#http_headers: | |
# Content-Type: application/x-font-ttf | |
#application/x-font-ttf | |
#application/octet-stream | |
- url: /fonts/(.*\.otf) | |
static_files: home/fonts/\1 | |
upload: home/fonts/(.*\.otf) | |
mime_type: application/x-font-otf | |
#http_headers: | |
# Content-Type: application/x-font-otf | |
- url: / | |
static_files: home/index.html | |
upload: home/index.html | |
#http_headers: | |
# Content-Type: text/html | |
- url: /index.html | |
static_files: home/index.html | |
upload: home/index.html | |
#http_headers: | |
# Content-Type: text/html | |
- url: /blog1.html | |
static_files: home/blog1.html | |
upload: home/blog1.html | |
#http_headers: | |
# Content-Type: text/html | |
- url: /maw.html | |
static_files: home/maw.html | |
upload: home/maw.html | |
#http_headers: | |
# Content-Type: text/html | |
- url: /about.html | |
static_files: home/about.html | |
upload: home/about.html | |
#http_headers: | |
# Content-Type: text/html | |
- url: /contact.html | |
static_files: home/contact.html | |
upload: home/contact.html | |
#http_headers: | |
# Content-Type: text/html | |
- url: /media.html | |
static_files: home/media.html | |
upload: home/media.html | |
#http_headers: | |
# Content-Type: text/html | |
- url: /favicon.ico | |
static_files: home/favicon.ico | |
upload: home/favicon.ico | |
#http_headers: | |
# Content-Type: image/x-icon | |
- url: /bin/.* | |
script: _go_app | |
#login: admin | |
#secure: always | |
#http_headers: | |
# Access-Control-Allow-Origin: "*" | |
inbound_services: | |
- warmup | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bin | |
import ( | |
"fmt" | |
"net/http" | |
) | |
func init() { | |
//http.HandleFunc("/", redirect("/home/index.html")) | |
//http.HandleFunc("/favicon.ico", redirect("/home/favicon.ico")) | |
http.HandleFunc("/bin/hello", hello) | |
http.HandleFunc("/bin/contact", contact) | |
} | |
func redirect(path string) func(http.ResponseWriter, *http.Request) { | |
return func (w http.ResponseWriter, r *http.Request) { | |
http.Redirect(w, r, path, http.StatusMovedPermanently) | |
} | |
} | |
func hello(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprint(w, "Hello, world!") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bin | |
import ( | |
"fmt" | |
"net/http" | |
netMail "net/mail" | |
"appengine" | |
"appengine/mail" | |
) | |
func contact(w http.ResponseWriter, r *http.Request) { | |
c := appengine.NewContext(r) | |
name := r.FormValue("name") | |
email := r.FormValue("email") | |
subject := r.FormValue("subject") | |
message := r.FormValue("message") | |
msg := &mail.Message{ | |
Sender: name + " <[email protected]>", | |
To: []string{"[email protected]"}, | |
ReplyTo: email, | |
Subject: subject, | |
Body: message, | |
Headers: netMail.Header{ | |
"On-Behalf-Of": []string{email}, | |
}, | |
} | |
if err := mail.Send(c, msg); err != nil { | |
c.Errorf("Couldn't send email: %v", err) | |
fmt.Fprint(w, "Mail NOT send! Error") | |
}else{ | |
fmt.Fprint(w, "Mail send.") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment