Created
May 17, 2013 00:05
-
-
Save okaq/5596075 to your computer and use it in GitHub Desktop.
Minimum Golang/Dartlang HTTP
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
// webserver.go | |
package main | |
import ( | |
"fmt" | |
"net/http" | |
// "net/url" | |
) | |
func AbHandler(w http.ResponseWriter, r *http.Request) { | |
fmt.Println(r.URL.Path) | |
if r.URL.Path == "/" { | |
http.ServeFile(w, r, "ab.html") | |
} | |
if r.URL.Path == "/js/ab.js" { | |
http.ServeFile(w, r, "ab.js") | |
} | |
} | |
func main() { | |
http.HandleFunc("/", AbHandler) | |
http.ListenAndServe(":8000", nil) | |
} | |
// ab.html | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>okaq.com</title> | |
<script src="/js/ab.js"></script> | |
</head> | |
<body> | |
</body> | |
</html> | |
// ab.dart | |
import 'dart:html' show Console; | |
void main() { | |
var console = new Console(); | |
console.log("ok ab dart!"); | |
} | |
// to compile use: | |
// dart2js -oab.js ab.dart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Forked your gist to format it the way a gist should be saved: https://gist.github.com/intel352/8059344