@@ -18,10 +18,7 @@ func RunApi(chapi chan bool, MyID uint32) {
1818 // python3 main.py を実行する
1919 cmd = exec .Command ("python3" , "main.py" )
2020 //コマンドを実行
21- err := cmd .Start ()
22- if err != nil {
23- log .Println (err )
24- }
21+ cmd .Start ()
2522 //ポートを開く
2623 listener , err := net .Listen ("tcp" , PORT )
2724 if err != nil {
@@ -147,7 +144,7 @@ func HandleRequest(conn net.Conn) {
147144
148145 }
149146
150- if strings .Split (requests [1 ], "/" )[1 ] == "changeAdjustment " {
147+ if strings .Split (requests [1 ], "/" )[1 ] == "changeadjustment " {
151148 // /changeadjustment/1,120,100/15,255,255/150/0.2これを受け取る
152149 // /120,100,15をとる
153150 minThreshold := strings .Split (requests [1 ], "/" )[2 ]
@@ -170,11 +167,11 @@ func HandleRequest(conn net.Conn) {
170167 fmt .Fprintf (conn , "CHANGE ADJUSTMENT OK\r \n " )
171168 // /changeadjustment/1,120,100/15,255,255/150/0.2を受け取ったら、jsonファイルを変更する
172169 // jsonファイルを変更する
173- file , err := os .OpenFile ("threshold.json" , os .O_RDWR | os .O_CREATE , 0755 )
170+
171+ os .Remove ("threshold.json" )
172+ file , err := os .Create ("threshold.json" )
174173 if err != nil {
175- fmt .Fprintf (conn , "HTTP/1.1 500 Internal Server Error\r \n " )
176- fmt .Fprintf (conn , "Content-Type: text/plain; charset=utf-8\r \n \r \n " )
177- fmt .Fprintf (conn , "500 Internal Server Error\r \n " )
174+ log .Println (err )
178175 }
179176 defer file .Close ()
180177 // jsonファイルに書き込む
0 commit comments