Skip to content

Commit

Permalink
sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
thesattiraju committed Sep 30, 2019
1 parent 6ef3ae4 commit eaca414
Show file tree
Hide file tree
Showing 12 changed files with 242 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM golang:latest
RUN mkdir /app
ADD . /app/
WORKDIR /app
RUN go get -d
RUN go build -o main .
RUN echo "Hello-world"
CMD ["/app/main"]
EXPOSE 80
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# go-sample
| -------- | --------|--------|
| Go Lang | Azure Web App, Virtual Machine, AKS| |

# Sample Go web application

This is a sample GO Lang web application that you can deploy to Azure.
58 changes: 58 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package main

import (
"fmt"
"html/template"
"log"
"net/http"
"os"
"github.com/Microsoft/ApplicationInsights-Go/appinsights"
)

type PageVars struct {
Message string
Language string
}

func main() {
client := appinsights.NewTelemetryClient(os.Getenv("APPINSIGHTS_INSTRUMENTATIONKEY"))
request := appinsights.NewRequestTelemetry("GET", "https://myapp.azurewebsites.net/", 1 , "Success")
client.Track(request)
http.Handle("/css/", http.StripPrefix("/css/", http.FileServer(http.Dir("css"))))
http.Handle("/img/", http.StripPrefix("/img/", http.FileServer(http.Dir("img"))))
http.Handle("/fonts/", http.StripPrefix("/fonts/", http.FileServer(http.Dir("fonts"))))
http.HandleFunc("/", Home)
log.Fatal(http.ListenAndServe(getPort(), nil))
}

func getPort() string {
p := os.Getenv("HTTP_PLATFORM_PORT")
if p != "" {
return ":" + p
}
return ":80"
}

func render(w http.ResponseWriter, tmpl string, pageVars PageVars) {

tmpl = fmt.Sprintf("views/%s", tmpl)
t, err := template.ParseFiles(tmpl)

if err != nil { // if there is an error
log.Print("template parsing error: ", err) // log it
}

err = t.Execute(w, pageVars) //execute the template and pass in the variables to fill the gaps

if err != nil { // if there is an error
log.Print("template executing error: ", err) //log it
}
}

func Home(w http.ResponseWriter, req *http.Request) {
pageVars := PageVars{
Message: "Success!",
Language: "Go Lang",
}
render(w, "index.html", pageVars)
}
134 changes: 134 additions & 0 deletions css/site.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
html,
body {
height: 100%;
width: 100%;
padding: 0;
margin: 0;
}
@font-face{
font-family: "Segoe UI";
src: url('../fonts/segoeuil.ttf');
}
.main-container {
height: 100%;
width: 100%;
background-color: #1d539d;
color: white;
padding-top: 6%;
box-sizing: border-box;
overflow-y: auto;
overflow-x: hidden;
font-family: "Segoe UI";
}

.cloud-image {
width: 1200px;
height: 250px;
padding-bottom: 50px;
margin: auto;
}

.success-text {
padding-bottom: 20px;
font-size: 62px;
line-height: 73px;
}

.description {
font-size: 34px;
line-height: 40px;
}

.next-steps-container {
padding-top: 50px;
}

.next-steps-header {
font-size: 24px;
line-height: 28px;
padding-bottom: 25px;
}

.next-steps-body {
display: flex;
flex-direction: column;
}

.step {
display: flex;
margin: 7px 0px;
font-size: 15px;
line-height: 21px;
}

.step-icon {
height: 20px;
width: 20px;
margin-right: 10px;
}

.step-text a {
color: white;
text-decoration: none;
}

.step-text a:hover {
color: white;
text-decoration:underline;
}

.content {
box-sizing: border-box;
min-width: 700px;
max-width: 830px;
position: relative;
margin: auto;
}

.tweet-container {
min-width: 30px;
min-height: 100px;
margin: 0 20px;
position: absolute;
left: -100px;
top: 110px;
}
.content-body{
min-width: 400px;
}

@media (max-width: 1024px) {
.main-container{
padding-top: 1%;
}
.cloud-image {
padding-bottom: 30px;
}
.next-steps-container {
padding-top: 30px;
}
.next-steps-header {
padding-bottom: 20px;
}
.success-text {
font-size: 50px;
line-height: 61px;
padding-bottom: 10px;
}
.description {
font-size: 26px;
line-height: 30px;
}

.step {
font-size: 12px;
line-height: 18px;
}
.tweet-container {
top: 80px;
}
.content{
max-width: 630px;
min-width: 630px;
}
}
Binary file added fonts/segoeuil.ttf
Binary file not shown.
1 change: 1 addition & 0 deletions img/cloneWhite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions img/deployWhite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions img/lightbulbWhite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions img/stackWhite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions img/successCloudNew.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions img/tweetThis.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions views/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!Doctype html>
<html>

<head>
<title>Go Lang Application</title>
<link href="css/site.css" rel="stylesheet">
</head>

<body>
<div class="main-container">
<div class="cloud-image">
<img src="img/successCloudNew.svg" />
</div>
<div class="content">
<div class="tweet-container">
<a href="http://twitter.com/intent/tweet/?text=I%20just%20created%20a%20new%20Go%20webapp%20on%20Azure%20using%20Azure%20DevOps%20Project&hashtags=AzureDevOpsProject%2CVSTS%20%40Azure%20%40VSTS">
<img src="img/tweetThis.svg" />
</a>
</div>
<div class="content-body">
<div class="success-text">{{.Message}}</div>
<div class="description line-2"> Your {{.Language}} app is up and running</div>
</div>
</div>
</div>
</div>
</body>

</html>

0 comments on commit eaca414

Please sign in to comment.