def hello(): web_datas = db_util2.get_data() nowClicks_web = web_datas['clicks_web'] print('web总点击量' + nowClicks_web) afterClicks_web = int(nowClicks_web) + 1 db_util2.set_clicks_web(str(afterClicks_web)) # 获取App实时点击量 token = 'A28UBH2TE8IT&' data = 'GET&%2Fctr_user_basic%2Fget_realtime_data&app_id%3D3103264374%26end_date%3D2017-11-11%26idx%3D10103%26start_date%3D2017-11-10' data = data.replace('~', '%7E').encode('utf-8') token = token.replace('-_', '+/').encode('utf-8') m = hmac.new(token, data, hashlib.sha1) data = hashlib.md5(m.hexdigest().encode('utf-8')) sign = data.hexdigest() result = requests.get( "http://openapi.mta.qq.com/ctr_user_basic/get_realtime_data?app_id=3103264374&start_date=2017-11-10&end_date=2017-11-11&idx=10103&sign=" + sign) app_click_data = result.json() print(app_click_data) clicks = app_click_data['ret_data']['SessionCount'] print('App实时启动量' + clicks) db_util2.set_clicks_app(clicks) return render_template('index.html')
def get_data(): now_users = db_util2.get_pxc_users() db_util2.set_users(now_users) app_version = db_util2.get_download_apk_info() data = db_util2.get_data() data['app_version'] = app_version['info']['serverVersion'] print(data) return jsonify(data)
def download_file(filename): # 需要知道2个参数, 第1个参数是本地目录的path, 第2个参数是文件名(带扩展名) print("进入接口") directory = r'/var/www/apk' data = db_util2.get_download_apk_info() print(data) serverVersion = data['info']['serverVersion'] new_fileName = filename + serverVersion + r'.apk' print(new_fileName) # 新增下载次数 web_data = db_util2.get_data() nowDownloads = web_data['downloads'] db_util2.set_downloads(int(nowDownloads) + 1) return send_from_directory(directory, new_fileName, as_attachment=True)