def statewisereport(): covid19 = covid(None, None) # Sorting state wise data according to the active cases statewisedata = (sorted(covid19.getstatewiseresults(), key=lambda i: int(i['active']), reverse=True)) return render_template('statewisereport.html', statedatalist=statewisedata)
def countrywisereport(): covid19 = covid(None, None) data = covid19.covidGlobal() globalDataList = data["Global"] countrywisedata = data["Countries"] return render_template('countrywisereport.html', globalData=globalDataList, countrydatalist=countrywisedata)
def ChennaiZoneCases(): covid19 = covid(None, None) try: response = covid19.getChennaizones() return jsonify({"success": True, "cases": response}) except Exception as e: print(e) return jsonify({"success": False})
def covidstats(state, district): State = state.title() District = district.title() covid19 = covid(State, District) data = covid19.getChennaiData() return render_template("covid19.html", data=data, District=District, State=State)
def covidstat(): State = "Tamil Nadu" District = "Chennai" covid19 = covid(State, District) data = covid19.getChennaiData() return render_template("covid19.html", data=data, District=District, State=State)
def get_covid(bot, update): text = update.message.text.split('/covid ') user = update.message.from_user.first_name l = len(text) if l == 2: country = text[1] logger.info(f'{user} requested covid for {country}') text = covid.detailed(country) elif l > 2: countries = text[1].split(',') countries = [i.lower().replace(' ', '') for i in countries] logger.info(f'{user} requested corona for {countries}') text = covid.covid(countries) else: text = covid.covid() logger.info(f'{user} requested covid') if text: bot.send_message(chat_id=update.message.chat_id, text=text, parse_mode=telegram.ParseMode.HTML)
def test(): list_states = lines totaldictionary = {} get_state = request.args.get('state', default='Tamil Nadu') covid19 = covid(get_state, None) data = covid19.getStateData()["districtData"] totaldictionary = covid19.totalstats(data) return render_template("hello_there.html", Statedata=data, State=get_state, totalstats=totaldictionary, Statelist=list_states)
def ChennaiStreetwiseCases(): covid19 = covid(None, None) try: response = covid19.getChennaiStreet() return jsonify({ "success": True, "title": response['title'], "chennaidata": response['chennaidata'] }) except Exception as e: print(e) return jsonify({"success": False})
def chennaistreetwise(): StreetChennaiCovid = covid(None, None) try: # with codecs.open('static/json/chennai_data_11.json','r', 'utf-8-sig') as f: # chennaidata = json.load(f) Chennai_Data = StreetChennaiCovid.getChennaiStreet() chennaiStreetData = Chennai_Data['chennaidata'] # print(chennaiStreetData) Datetitle = Chennai_Data['title'] return render_template('chennaicovidlist.html', chennailist=chennaiStreetData, datetitle=Datetitle) except Exception as e: print(e) return render_template("error-404.html")
def countrywisereport(): covid19 = covid(None, None) try: data = covid19.covidGlobal() globalDataList = data["Global"] countrywisedata = data["Countries"] for countries in countrywisedata: countries['TotalActive'] = (countries['TotalConfirmed'] - countries['TotalDeaths'] - countries['TotalRecovered']) return render_template('countrywisereport.html', globalData=globalDataList, countrydatalist=countrywisedata) except Exception as e: # return 404 page if error occurs return render_template("error-404.html")
def covidHome(): list_states = lines totaldictionary = {} try: get_state = request.args.get('state', default='Tamil Nadu') covid19 = covid(get_state, None) data = covid19.getStateData()["districtData"] # Data Sorting as per the number of active cases sorted_data = OrderedDict( sorted(data.items(), key=lambda x: getitem(x[1], 'active'), reverse=True)) totaldictionary = covid19.totalstats(data) return render_template("covidtable.html", Statedata=sorted_data, State=get_state, totalstats=totaldictionary, Statelist=list_states) except Exception as e: print(e) return render_template("error-404.html")
def statewisereport(): covid19 = covid(None, None) statewisedata = covid19.getstatewiseresults() return render_template('statewisereport.html', statedatalist=statewisedata)
def chennaizonalreport(): covid19 = covid(None, None) try: response = covid19.getChennaizones() #Fetching the Date from first key FormattedDate = datetime.strptime(response[0]['date'].strip(), "%Y-%m-%d").strftime("%A, %d %b %Y") zones_chennai = response[:16] zones_chennaiOneday = response[16:32] Last_twentydays = response[:16 * 30] #Chennai Data Charts Chennai_dict = {} chennai_date = [] chennai_confirmed = [] chennai_recovered = [] chennai_hospitalized = [] chennai_deceased = [] for k, v in groupby(Last_twentydays, key=lambda x: x['date'].strip()): tot1 = tot2 = tot3 = tot4 = 0 # Chennai_dict[k] = sorted(list(v),key=lambda x: datetime.strptime(x['date'].strip(), '%Y-%m-%d')) for item in v: tot1 += item['confirmedCases'] tot2 += item['recovered'] tot3 += item['hospitalized'] tot4 += item['deceased'] chennai_confirmed.append(tot1) chennai_recovered.append(tot2) chennai_hospitalized.append(tot3) chennai_deceased.append(tot4) chennai_date.append( datetime.strptime(k.strip(), "%Y-%m-%d").strftime("%b %d")) #To Reverse Chennai_dict['date'] = chennai_date[::-1] Chennai_dict['confirmedCases'] = chennai_confirmed[::-1] Chennai_dict['recovered'] = chennai_recovered[::-1] Chennai_dict['hospitalized'] = chennai_hospitalized[::-1] Chennai_dict['deceased'] = chennai_deceased[::-1] #Area Wise Charts data dict_list = {} Last_twentydays.sort(key=lambda x: x['zoneName']) for k, v in groupby(Last_twentydays, key=lambda x: x['zoneName']): dict_list[k] = sorted( list(v), key=lambda x: datetime.strptime(x['date'].strip(), '%Y-%m-%d')) # zones_list = list(zones_chennai['zoneName'].values()) zones_list = [ zones_list['zoneName'].capitalize() for zones_list in zones_chennai ] active_list = [ active_list['hospitalized'] for active_list in zones_chennai ] recovered_list = [ recovered_list['recovered'] for recovered_list in zones_chennai ] deceased_list = [ deceased_list['deceased'] for deceased_list in zones_chennai ] # active_list1, recovered_list1, deceased_list1 = [] active_list1 = [ active_list1['hospitalized'] for active_list1 in zones_chennaiOneday ] recovered_list1 = [ recovered_list1['recovered'] for recovered_list1 in zones_chennaiOneday ] deceased_list1 = [ deceased_list1['deceased'] for deceased_list1 in zones_chennaiOneday ] return render_template('chennaizonewise.html', onlychennai_data=Chennai_dict, chennaidata=zones_chennai, formatteddate=FormattedDate, zones_list=zones_list, active_list=active_list, recovered_list=recovered_list, deceased_list=deceased_list, fivedaysstat=dict_list, active_list1=active_list1, recovered_list1=recovered_list1, deceased_list1=deceased_list1) except Exception as e: # return 404 page if error occurs print("error in chennai route " + e) return render_template("error-404.html")
def covidstats(message): bot.reply_to(message, covid(message))