api.py 917 Bytes
Newer Older
1
2
3
4
# api.py

from flask import Flask, jsonify

5
6
7
8
9
# TODO: Adding correct path to ASYST script run_LR_SBERT.py
# from run_LR_SBERT import main

# sys.path.append(os.path.join(os.path.dirname(__file__), 'asyst/Source/Skript/german'))

10
11
12
13
app = Flask(__name__)

@app.route('/api/data', methods=['GET'])
def get_data():
14
15
16
17
18
19
20
21
22
    # Using path to data and model
    data_path = '/var/www/html/moodle/asyst/Source/Skript/outputs/test.tsv'
    model_dir = '/var/www/html/moodle/asyst/Source/Skript/german/models'

    # Obtaining results from run_asyst function
#     results => run_asyst(data_path, model_dir)

    # Demo dummy API output
    results = {
23
24
25
26
27
28
        'message': 'Hello from Python API!',
        'data': {
            'key1': 'value1',
            'key2': 'value2'
        }
    }
29
30
31

    # Returning result in JSON format
    return jsonify(results)
32
33
34

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