提交 783d26fc 编写于 作者: chai2010's avatar chai2010

本地 play 支持凹中文

上级 ca4bc40a
......@@ -3,6 +3,7 @@
package appplay
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
......@@ -28,7 +29,12 @@ func (p *WebServer) fmtHandler(w http.ResponseWriter, r *http.Request) {
}
func (p *WebServer) fmtCode(code []byte) (*fmtResponse, error) {
output, err := api.FormatCode("prog.wa", string(code))
filename := "prog.wa"
if bytes.Contains(code, []byte("【启】:")) {
filename = "prog.wz"
}
output, err := api.FormatCode(filename, string(code))
if err != nil {
resp := &fmtResponse{
Error: err.Error(),
......
......@@ -3,6 +3,7 @@
package appplay
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
......@@ -41,7 +42,12 @@ func (p *WebServer) compileAndRun(req *Request) (*Response, error) {
}
defer os.RemoveAll(tmpDir)
result, err := api.RunCode(api.DefaultConfig(), "prog.wa", req.Body)
filename := "prog.wa"
if bytes.Contains([]byte(req.Body), []byte("【启】:")) {
filename = "prog.wz"
}
result, err := api.RunCode(api.DefaultConfig(), filename, req.Body)
if err != nil {
resp := &Response{Errors: err.Error()}
return resp, nil
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册