-
Notifications
You must be signed in to change notification settings - Fork 0
/
rookk_main.py
47 lines (40 loc) · 1.14 KB
/
rookk_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
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/7/4 下午8:42
# @Author : Aries
# @Site :
# @File : rookk_main.py
# @Software: PyCharm Community Edition
import os
import json
import traceback
from redis_helper import RedisHelper
from flask import Flask, session
from flask import request
from controller.caculate import CaculateRisk
redis_helper = RedisHelper()
app = Flask(__name__)
@app.route('/')
def index():
return 'this is index...'
@app.route('/Alldata', methods=['POST'])
def alldata():
Result = 1
content = {}
json_return = {}
try:
app.logger.debug('request get...')
cr = CaculateRisk(request.json)
sapsi5, arthritis6, pr7 = cr.caculate()
content = {'saPASI': int(sapsi5), 'Arthritis6': int(arthritis6), 'PR7': round(pr7, 2) if pr7 else None}
redis_helper.public(cr.content())
except Exception as e:
traceback.print_exc()
app.logger.exception(e)
Result = 2
if content:
json_return = content
json_return['Result'] = Result
return json.dumps(json_return)
if __name__ == '__main__':
app.run(port=9160, debug=True)