File size: 844 Bytes
6cc974b
 
 
 
 
 
 
bd5fed1
6cc974b
 
 
367a8ae
6cc974b
 
 
bd5fed1
8bfa0d2
668189f
bd5fed1
6cc974b
 
 
 
 
 
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
import os
import sys
from flask import Flask, jsonify, request, app
from flask_cors import CORS
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.dirname(current_dir)
sys.path.append(parent_dir)
from model_prediction_wrapper import slice_sentences

app = Flask(__name__)

CORS(app, resources={r"/api/*": {"origins": "https://procid-git.github.io"}})

@app.route('/api/predict', methods=['POST'])
def get_ai_prediction():
    if 'aiImage' not in request.files:
        return jsonify({"prediction": "Error, no file uploaded"}), 400
    image = request.files['aiImage']
    ai_prediction = slice_sentences(image.stream)
    return jsonify({"prediction": ai_prediction})


if __name__ == "__main__":
    port = int(os.environ.get("PORT", 7860))
    app.run(host="0.0.0.0", port=port, debug=True)