11# -*- coding: utf-8 -*-
22from flask import Flask , request , abort , Response , send_from_directory
3- # import matplotlib.pyplot as plt
4- # from matplotlib.ticker import MaxNLocator
3+ import matplotlib .pyplot as plt
4+ from matplotlib .ticker import MaxNLocator
55import requests
66import json
77import MySQLdb
@@ -504,7 +504,7 @@ def draw_chart(chart_data,recieved_mails,expected_mails,pie):
504504def list_statistics (chatId ,message ):
505505 batches = values ['batches' ]
506506 summary_message = "Statistics of "
507- # os.chdir('/home/sandeshghanta/mysite/')
507+ os .chdir ('/home/sandeshghanta/mysite/' )
508508 args = list (message .strip ().split ())
509509
510510 try :
@@ -663,7 +663,7 @@ def list_statistics(chatId,message):
663663 recieved_mails = recieved_mails + sent
664664 expected_mails = expected_mails + total_no_of_students_in_batches
665665 chart_data .append ((file_name ,sent ,total_no_of_students_in_batches ))
666- except : #have to change it to except FileNotFoundError before deploying and then have to check it it works in server
666+ except FileNotFoundError :
667667 #send_admin_message(file_name+'.txt' + " is not there in the server!!!")
668668 do_nothing = 1
669669 start_date = start_date + datetime .timedelta (days = 1 )
@@ -788,8 +788,7 @@ def handle_request(request_data):
788788
789789@app .route ("/" + values ['bot_token' ], methods = ['GET' ,'POST' ])
790790def webhook ():
791- #request_data = request.get_json()
792- request_data = {"update_id" : 727334728 , "message" : {"date" : 1537694939 , "text" : "/statistics -i sghanta05@gmail.com -d -pie" , "entities" : [{"offset" : 0 , "type" : "bot_command" , "length" : 5 }], "chat" : {"first_name" : "Sandesh" , "type" : "private" , "last_name" : "Ghanta" , "id" : 314219342 , "username" : "sandeshghanta" }, "message_id" : 94 , "from" : {"is_bot" : False , "username" : "sandeshghanta" , "language_code" : "en-IN" , "id" : 314219342 , "first_name" : "Sandesh" , "last_name" : "Ghanta" }}}
791+ request_data = request .get_json ()
793792 chatId = ""
794793 if ('message' in request_data ):
795794 try :
@@ -814,6 +813,5 @@ def get_file(path):
814813 return send_from_directory (UPLOAD_DIRECTORY , path , as_attachment = True )
815814
816815if __name__ == '__main__' :
817- #os.chdir('/home/sandeshghanta/mysite/')
818- #app.run(host='0.0.0.0',port="1234")
819- webhook ()
816+ os .chdir ('/home/sandeshghanta/mysite/' )
817+ app .run (host = '0.0.0.0' ,port = "1234" )
0 commit comments