├── .gitignore
├── tutorial_3
├── README.md
├── web
│ ├── test.html
│ ├── books_design.html
│ └── books.html
└── main.go
├── README.md
├── tutorial_1
├── README.md
├── main.go
└── web
│ └── test.html
└── tutorial_2
├── README.md
├── web
├── test.html
└── chat.html
└── main.go
/.gitignore:
--------------------------------------------------------------------------------
1 | *.exe
2 | .idea
3 |
4 |
--------------------------------------------------------------------------------
/tutorial_3/README.md:
--------------------------------------------------------------------------------
1 | Tutorial 3
2 | ==========
3 |
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | webapp tutorial
2 | ======================
3 |
4 | This tutorial series will help you get a web application up and running using the following technologies:
5 |
6 | * Go for developing the backend
7 | * Angularjs for developing the frontend
8 | * Bootstrap and Font-Awesome for page layout and icons
9 |
10 | Click on each of the folders above to view the code and READMEs for each tutorial.
11 |
--------------------------------------------------------------------------------
/tutorial_1/README.md:
--------------------------------------------------------------------------------
1 | Tutorial 1
2 | ==========
3 |
4 | In this first tutorial we get up and running with a basic web server that
5 | serves any files in the local directory.
6 |
7 | How to run
8 | -------------
9 |
10 | * Install Go
11 | * http://golang.org/doc/install
12 | * Download this project from github and unzip
13 | * https://github.com/jakecoffman/golang-webapp-tutorial/archive/master.zip
14 | * Open a command window and `cd` to the tutorial_1 directory
15 | * Type `go run main.go` to start the server
16 | * Open a web browser and go to http://localhost/
17 |
18 | If you get a message that says "It works!" then it's working.
19 |
--------------------------------------------------------------------------------
/tutorial_2/README.md:
--------------------------------------------------------------------------------
1 | Tutorial 1
2 | ==========
3 |
4 | In this first tutorial we get up and running with a basic web server that
5 | serves any files in the local directory.
6 |
7 | How to run
8 | -------------
9 |
10 | * Install Go
11 | * http://golang.org/doc/install
12 | * Download this project from github and unzip
13 | * https://github.com/jakecoffman/golang-webapp-tutorial/archive/master.zip
14 | * Open a command window and `cd` to the tutorial_1 directory
15 | * Type `go run main.go` to start the server
16 | * Open a web browser and go to http://localhost/
17 |
18 | If you get a message that says "It works!" then it's working.
19 |
--------------------------------------------------------------------------------
/tutorial_1/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | "log"
7 | "net/http"
8 | )
9 |
10 | func main() {
11 | // command line flags
12 | port := flag.Int("port", 80, "port to serve on")
13 | dir := flag.String("directory", "web/", "directory of web files")
14 | flag.Parse()
15 |
16 | // handle all requests by serving a file of the same name
17 | fs := http.Dir(*dir)
18 | fileHandler := http.FileServer(fs)
19 | http.Handle("/", fileHandler)
20 |
21 | log.Printf("Running on port %d\n", *port)
22 |
23 | addr := fmt.Sprintf("127.0.0.1:%d", *port)
24 | // this call blocks -- the progam runs here forever
25 | err := http.ListenAndServe(addr, nil)
26 | fmt.Println(err.Error())
27 | }
28 |
--------------------------------------------------------------------------------
/tutorial_1/web/test.html:
--------------------------------------------------------------------------------
1 |
2 |