Last active
January 4, 2016 14:39
-
-
Save okaq/8635831 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// okaq vaki | |
// font engine | |
// bitmap font sampled from | |
// canvas fillText render | |
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" | |
) | |
const ( | |
HTML_PATH = "vaki.html" | |
MOTD = "Hello. okaq vaki web app is live\nRunning on port: \n" | |
PORT = ":8082" | |
) | |
var ( | |
B []byte | |
) | |
func Cache() { | |
var err error | |
B, err = ioutil.ReadFile(HTML_PATH) | |
if err != nil { | |
log.Fatal(err) | |
} | |
} | |
func Serve() { | |
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { | |
fmt.Println(req.RemoteAddr, req.RequestURI, req.Method) | |
w.Write(B) | |
}) | |
http.ListenAndServe(PORT, nil) | |
} | |
func Greet() { | |
fmt.Println(MOTD, PORT) | |
} | |
func main() { | |
Greet() | |
Cache() | |
Serve() | |
} |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>okaq - vaki</title> | |
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAMklEQVR4nGJpP/GBgZaAiaamj1owasGoBaMWjFowasGoBaMWjFowasGoBVQEgAAAAP//7R0Cgi3xzjwAAAAASUVORK5CYII=" /> | |
<script type="text/javascript"> | |
// ok | |
console.log("ok vaki!"); | |
// async load | |
(function() { | |
var async_load = function() { | |
console.log("async on"); | |
g.init(); | |
} | |
window.addEventListener("load", async_load, false); | |
})(); | |
// game | |
var g = { | |
"init": function() { | |
console.log("g init"); | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<canvas id="beta" width="512" height="512"></canvas> | |
<canvas id="gamma" width="768" height="768"></canvas> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment