-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (25 loc) · 1.14 KB
/
main.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
35
36
import json
from flask import Flask, request, current_app
from collections import OrderedDict
from extract_keyword import get_keyword
app = Flask(__name__)
def api_response(status, message, data):
return current_app.response_class(
json.dumps(OrderedDict([('status', status), ('message', message), ('data', data)]),
indent=None), mimetype='application/json')
@app.route('/api/v1/keyword', methods=['POST'])
def post_keyword():
try:
application = request.get_json()['application']
if application == "":
return api_response(200, "키워드 추출 성공", {"keywordTop5": ["", "", "", "", ""], "softSkills": ["", "", "", "", ""]}), 200
keyword_top5, soft_skills = get_keyword(application)
return api_response(200, "키워드 추출 성공", {"keywordTop5": keyword_top5, "softSkills": soft_skills}), 200
except Exception as e:
print("Something wrong!!", e)
return api_response(500, "Internal Server Error", str(e)), 500
@app.route('/')
def health_check():
return 'Hello, World!'
if __name__ == '__main__':
app.run('0.0.0.0', port=8000, debug=True)