lyangas commited on
Commit
d5e3dc4
1 Parent(s): 4a7adf1

add encoding from base64

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -1,4 +1,5 @@
1
  print('INFO: import modules')
 
2
  from flask import Flask, request
3
  import json
4
  import pickle
@@ -45,8 +46,10 @@ def test():
45
  @app.route("/predict", methods=['POST'])
46
  def read_root():
47
  data = request.json
48
- print(data)
49
- text = str(data['text'])
 
 
50
  top_n = int(data['top_n'])
51
 
52
  if top_n < 1:
 
1
  print('INFO: import modules')
2
+ import base64
3
  from flask import Flask, request
4
  import json
5
  import pickle
 
46
  @app.route("/predict", methods=['POST'])
47
  def read_root():
48
  data = request.json
49
+ base64_bytes = str(data['text']).encode("ascii")
50
+ sample_string_bytes = base64.b64decode(base64_bytes)
51
+ text = sample_string_bytes.decode("ascii")
52
+ # text = str(data['text'])
53
  top_n = int(data['top_n'])
54
 
55
  if top_n < 1: