|
1 | | -import collections, logging, os, requests, signal, time |
| 1 | +import collections, json, logging, os, requests, signal, time |
2 | 2 | from tornado import httpserver, ioloop, web |
3 | 3 |
|
4 | 4 |
|
@@ -27,14 +27,17 @@ def delete(self): |
27 | 27 |
|
28 | 28 | class UploadHandler(web.RequestHandler): |
29 | 29 | def post(self): |
30 | | - file_des = self.request.files['file'][0] |
31 | | - file_name = temp_img_prefix + file_des['filename'] |
32 | | - rel_path = static_img_path + file_name |
33 | | - output_file = open(rel_path, 'wb') |
34 | | - output_file.write(file_des['body']) |
35 | | - output_file.close() |
36 | | - caption = run_ml(rel_path) |
37 | | - self.finish({"file_name": rel_path, "caption": caption}) |
| 30 | + finish_ret = [] |
| 31 | + new_files = self.request.files['file'] |
| 32 | + for file_des in new_files: |
| 33 | + file_name = temp_img_prefix + file_des['filename'] |
| 34 | + rel_path = static_img_path + file_name |
| 35 | + output_file = open(rel_path, 'wb') |
| 36 | + output_file.write(file_des['body']) |
| 37 | + output_file.close() |
| 38 | + caption = run_ml(rel_path) |
| 39 | + finish_ret.append({"file_name": rel_path, "caption": caption}) |
| 40 | + self.finish(json.dumps(finish_ret)) |
38 | 41 |
|
39 | 42 |
|
40 | 43 | # Runs ML on given image |
|
0 commit comments