-
Notifications
You must be signed in to change notification settings - Fork 12
/
server.py
49 lines (47 loc) · 1.31 KB
/
server.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import tornado.ioloop
import tornado.web
import json
import six
import nltk
import math
import numpy as np
import collections
import unicodedata
import re
import sys
import os
from tornado.httpserver import *
#from predict import *
import threading
attr = ["NAME","ATK", "DEF", "COST","DUR","TYPE","PLAYER_CLS", "RACE","RARITY"]
dir = {"ATIS":"ATIS", "GEO":"GEO", "HS":"Compare"}
import psutil
import os
import subprocess
print ("load")
class UploadFileHandler(tornado.web.RequestHandler):
def post(self):
self.set_header('Access-Control-Allow-Origin', "*")
print(self.request.body)
content = self.request.body.decode('utf-8')
print(content)
data = json.loads(content)
res = ""
ans = "fail to generate"
print("post")
if(data['type'] == 'Repair'):
open("code.java", "w").write(data['data'])
open("line.txt", 'w').write(data['data1'])
os.system("python3 testone.py")
f = open("ans.txt", "r")
ans = f.read()
f.close()
self.finish(ans)
app=tornado.web.Application([
(r'/', UploadFileHandler),
])
if __name__ == '__main__':
server = HTTPServer(app)
server.listen(12000)
#app.listen(12000)
tornado.ioloop.IOLoop.instance().start()