mirror of
https://github.com/adanrsantos/ThePlaceHolders.git
synced 2024-12-16 14:20:39 -06:00
Compare commits
No commits in common. "47a3550430186a9e7beb0dcb1e3b6de83ed9fca0" and "260bda45a951be70bba4b728abf1e863a09a2526" have entirely different histories.
47a3550430
...
260bda45a9
|
@ -7,9 +7,6 @@ within a restricted amount of time to make art.
|
||||||
2. Run the command `go run .` inside this folder
|
2. Run the command `go run .` inside this folder
|
||||||
3. View the website at [127.0.0.1:8080](http://127.0.0.1:8080/)
|
3. View the website at [127.0.0.1:8080](http://127.0.0.1:8080/)
|
||||||
|
|
||||||
You can choose a different IP address or port using the flags:
|
|
||||||
`go run . -ip=192.168.0.1 -port=3000`
|
|
||||||
|
|
||||||
## Go project structure
|
## Go project structure
|
||||||
* [go.mod](go.mod) Go version and library dependencies
|
* [go.mod](go.mod) Go version and library dependencies
|
||||||
* [go.sum](go.sum) Checksums for libraries
|
* [go.sum](go.sum) Checksums for libraries
|
||||||
|
@ -27,4 +24,4 @@ CSS framework.
|
||||||
* [Registration page](static/register.html)
|
* [Registration page](static/register.html)
|
||||||
|
|
||||||
yaya
|
yaya
|
||||||
testing
|
testing
|
13
server.go
13
server.go
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -9,6 +8,9 @@ import (
|
||||||
"github.com/gorilla/sessions"
|
"github.com/gorilla/sessions"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const ADDRESS = "127.0.0.1"
|
||||||
|
const PORT = "8080"
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
// Registered user information
|
// Registered user information
|
||||||
Users map[string]UserData
|
Users map[string]UserData
|
||||||
|
@ -17,11 +19,6 @@ type Server struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
ipFlag := flag.String("ip", "127.0.0.1", "IP address to receive traffic from")
|
|
||||||
portFlag := flag.String("port", "8080", "Port to receive traffic from")
|
|
||||||
flag.Parse()
|
|
||||||
address := *ipFlag
|
|
||||||
port := *portFlag
|
|
||||||
// Create server object
|
// Create server object
|
||||||
secret := []byte("super-secret-key")
|
secret := []byte("super-secret-key")
|
||||||
server := Server{
|
server := Server{
|
||||||
|
@ -43,8 +40,8 @@ func main() {
|
||||||
})
|
})
|
||||||
http.HandleFunc("/secret", server.secret)
|
http.HandleFunc("/secret", server.secret)
|
||||||
// Start web server at 127.0.0.1:8080
|
// Start web server at 127.0.0.1:8080
|
||||||
fmt.Printf("Listening to %s on port %s...\n", address, port)
|
fmt.Printf("Listening to %s on port %s...\n", ADDRESS, PORT)
|
||||||
err := http.ListenAndServe(address+":"+port, nil)
|
err := http.ListenAndServe(ADDRESS+":"+PORT, nil)
|
||||||
// Print any errors
|
// Print any errors
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error starting server:")
|
fmt.Println("Error starting server:")
|
||||||
|
|
Loading…
Reference in a new issue