api.py 697 Bytes
Newer Older
1
2
# api.py

3
4
5
from flask import Flask, jsonify, request
import os
import sys
6

7
8
# Adding a path of module to system path
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'asyst/Source/Skript/german')))
9

10
from run_LR_SBERT import process_data
11

12
13
app = Flask(__name__)

14
@app.route('/api/autograde', methods=['POST'])
15
def get_data():
16
17
18
19
20
21
22
23
24
    try:
        data = request.get_json()
        if not data:
            return jsonify({"error": "No data provided"}), 400

        results = process_data(data)
        return jsonify(results)
    except Exception as e:
        return jsonify({"error": str(e)}), 500
25
26
27

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=True)