-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
34 lines (24 loc) · 983 Bytes
/
app.py
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
26
27
28
29
30
31
32
33
34
from flask import Flask, request, jsonify
from bio_medical_ner_parser import BioMedicalParser
import logging
# Configure logging
logging.basicConfig(filename='bio_medical_ner.log', level=logging.ERROR, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
app = Flask(__name__)
bio_medical_parser = BioMedicalParser()
@app.route('/health', methods=['GET'])
def health_check():
#Is api active
status = {'status': 'Bio-Medical-NER API is Live'}
return jsonify(status), 200
@app.route('/bio-medical-ner/query', methods=['POST'])
def handle_bio_medical_ner_query():
try:
query = request.form.get('input_text')
response=bio_medical_parser.extract_biomedical_entities(query)
return jsonify({'response': response})
except Exception as e:
app.logger.error(f'Error handling query: {str(e)}')
return jsonify({'error': str(e)}), 500
if __name__ == "__main__":
# app.run()
app.run(host="0.0.0.0",port=5000)