|
|
|
|
|
|
142
|
var homePageTemplate = template.Must(template.New("homepage").Parse(homePageTemplateStr))
|
142
|
var homePageTemplate = template.Must(template.New("homepage").Parse(homePageTemplateStr))
|
|
143
|
|
143
|
|
|
144
|
func runServer() {
|
144
|
func runServer() {
|
|
145
|
fmt.Printf("running on %s\n", *address)
|
|
|
|
|
|
145
|
address := fmt.Sprintf("%s:%d", *host, *port)
|
|
|
|
146
|
fmt.Printf("running on %s\n", address)
|
|
146
|
|
147
|
|
|
147
|
http.HandleFunc("/run", runCodeHandler)
|
148
|
http.HandleFunc("/run", runCodeHandler)
|
|
148
|
http.HandleFunc("/codemirror.js", func(w http.ResponseWriter, r *http.Request) {
|
149
|
http.HandleFunc("/codemirror.js", func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
|
153
|
})
|
154
|
})
|
|
154
|
http.HandleFunc("/", homePageHandler)
|
155
|
http.HandleFunc("/", homePageHandler)
|
|
155
|
|
156
|
|
|
156
|
err := http.ListenAndServe(*address, nil)
|
|
|
|
|
|
157
|
err := http.ListenAndServe(address, nil)
|
|
157
|
if err != nil {
|
158
|
if err != nil {
|
|
158
|
log.Fatal(err)
|
159
|
log.Fatal(err)
|
|
159
|
}
|
160
|
}
|
|
|
|
|
|
|
244
|
}
|
245
|
}
|
|
245
|
|
246
|
|
|
246
|
var language = flag.String("l", "", "The language to use for code passed via stdin.")
|
247
|
var language = flag.String("l", "", "The language to use for code passed via stdin.")
|
|
247
|
var address = flag.String("addr", "localhost:8000", "The host and port to listen on.")
|
|
|
|
|
|
248
|
var host = flag.String("h", "localhost", "The host to listen on.")
|
|
|
|
249
|
var port = flag.Int("p", 8000, "The port to listen on.")
|
|
248
|
|
250
|
|
|
249
|
func main() {
|
251
|
func main() {
|
|
250
|
cmd, args := parseCommand()
|
252
|
cmd, args := parseCommand()
|