Commit 6d8c1a0d authored by 류은제's avatar 류은제
Browse files

Update app.py

parent 45c6aa33
...@@ -209,10 +209,8 @@ def extract_utilization(): ...@@ -209,10 +209,8 @@ def extract_utilization():
result_dict ={"results":result_dict} result_dict ={"results":result_dict}
# convert type dict to json # json 결과값을 Content-type: application/json으로 반환하도록 jsonify 사용
result_json=json.dumps(result_dict) result_json=jsonify(result_dict)
print(result_json)
return result_json return result_json
...@@ -227,10 +225,7 @@ app = Flask(__name__) ...@@ -227,10 +225,7 @@ app = Flask(__name__)
def myfunction_api(): def myfunction_api():
result = extract_utilization() result = extract_utilization()
return result
# json 결과값을 Content-type: application/json으로 반환하도록 jsonify 사용
return jsonify(result)
if __name__ == "__main__": if __name__ == "__main__":
...@@ -239,11 +234,3 @@ if __name__ == "__main__": ...@@ -239,11 +234,3 @@ if __name__ == "__main__":
# api url # api url
# http://10.231.238.231:31000/api/getMonitoring # http://10.231.238.231:31000/api/getMonitoring
'''
result (type: json)
"{\"results\": {\"item1\": {\"id\": \"i-ai-1\", \"cpu\": 4.08, \"cuda\": 53.25, \"mem\": \"4.76\", \"disk\": \"25.02\"}, \"item2\": {\"id\": \"i-ai-2\", \"cpu\": 5.27, \"cuda\": 45.25, \"mem\": \"7.41\", \"disk\": \"8.44\"}, \"item3\": {\"id\": \"i-ai-3\", \"cpu\": 1.41, \"cuda\": 20.62, \"mem\": \"4.13\", \"disk\": \"8.27\"}, \"item4\": {\"id\": \"i-ai-4\", \"cpu\": 4.16, \"cuda\": 37.5, \"mem\": \"5.46\", \"disk\": \"8.35\"}, \"item5\": {\"id\": \"i-ai-5\", \"cpu\": 1.08, \"cuda\": 33.88, \"mem\": \"8.98\", \"disk\": \"41.02\"}, \"item6\": {\"id\": \"i-ai-6\", \"cpu\": 0.12, \"cuda\": 0.0, \"mem\": \"1.15\", \"disk\": \"90.91\"}, \"time\": \"2023-03-06T19:38:45.710251+09:00\"}}"
'''
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment