-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
32 lines (25 loc) · 986 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"fmt"
"net/http"
"os"
"github.com/skycoin/cx-playground/playground"
"github.com/skycoin/cx-playground/webapi"
"github.com/skycoin/cx/cxparser/actions"
)
func main() {
workingDir, _ := os.Getwd()
if err := playground.InitPlayground(workingDir); err != nil {
// error captured while initiating the playground examples, should be handled in the future
fmt.Println("Fail to initiating playground examples")
}
http.HandleFunc("/playground/examples", playground.GetExampleFileList)
http.HandleFunc("/playground/examples/code", playground.GetExampleFileContent)
http.Handle("/", http.FileServer(http.Dir("./dist")))
http.Handle("/program/", webapi.NewAPI("/program", actions.AST))
http.HandleFunc("/eval", playground.RunProgram)
http.HandleFunc("/mem", playground.GetMemStatus)
http.HandleFunc("/showast", playground.ShowAst)
fmt.Println("Starting web service for CX playground on http://127.0.0.1:5336/")
http.ListenAndServe(":5336", nil)
}