-
Notifications
You must be signed in to change notification settings - Fork 1
/
ml_server.py
39 lines (30 loc) · 979 Bytes
/
ml_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
from fontto_pix2pix import fontto_pix2pix
import json
from flask import Flask, request
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
app = Flask(__name__)
def backgroundProcessing(request):
# print log
print("start : backgroundProcessing")
body = request.json
input_urls = body['urls']
count = body['count']
env = body['env']
reuse_unicode = body['reuse_unicode']
url_class = fontto_pix2pix(input_urls, count, env, reuse_unicode)
# print log
print("finish : backgroundProcessing")
return url_class
@app.route('/fontto/processing', methods=['POST'])
def processing_fontto():
return json.dumps(backgroundProcessing(request))
@app.route('/')
def test_root():
return 'OK'
if __name__ == '__main__':
http_server = HTTPServer(WSGIContainer(app))
http_server.listen(5959)
IOLoop.instance().start()
# app.run(port=5959, debug=True)