thejagstudio commited on
Commit
3c43385
·
verified ·
1 Parent(s): 44592f2

Update home/views.py

Browse files
Files changed (1) hide show
  1. home/views.py +14 -5
home/views.py CHANGED
@@ -18,7 +18,19 @@ import geocoder
18
  import folium
19
 
20
  gauth = GoogleAuth()
21
- print(gauth.GetAuthUrl())
 
 
 
 
 
 
 
 
 
 
 
 
22
  DRIVE = GoogleDrive(gauth)
23
 
24
 
@@ -30,6 +42,7 @@ def GoogleDriveUpload(filename, folder):
30
 
31
  @csrf_exempt
32
  def index(request):
 
33
  context = {
34
  'user': request.user
35
  }
@@ -187,10 +200,6 @@ def emailSender(request):
187
  send_mail(subject, message, from_email, [to_email], fail_silently=True)'''
188
  return redirect('index')
189
 
190
- # http://127.0.0.1:8000/emailSender/?name=jagrat%20patel&[email protected]&subject=sdsd&message=sdsfs
191
- # https://script.google.com/macros/s/AKfycbwQxoJPZYttDmLEym7btUB2F-KIbvITr9EWSdfC5TaYJZybnA-s/[email protected]&subject=hello&body=world&html=false
192
-
193
-
194
  def ipGetter(request):
195
  ip = request.GET.get('ip', '')
196
  ipIn = ip_address.objects.filter(ip=ip).first()
 
18
  import folium
19
 
20
  gauth = GoogleAuth()
21
+ gauth.LoadCredentialsFile("mycreds.txt")
22
+ authUrl = gauth.GetAuthUrl()
23
+ if gauth.credentials is None:
24
+ # Authenticate if they're not there
25
+ gauth.LocalWebserverAuth()
26
+ elif gauth.access_token_expired:
27
+ # Refresh them if expired
28
+ gauth.Refresh()
29
+ else:
30
+ # Initialize the saved creds
31
+ gauth.Authorize()
32
+ # Save the current credentials to a file
33
+ gauth.SaveCredentialsFile("mycreds.txt")
34
  DRIVE = GoogleDrive(gauth)
35
 
36
 
 
42
 
43
  @csrf_exempt
44
  def index(request):
45
+ print(authUrl)
46
  context = {
47
  'user': request.user
48
  }
 
200
  send_mail(subject, message, from_email, [to_email], fail_silently=True)'''
201
  return redirect('index')
202
 
 
 
 
 
203
  def ipGetter(request):
204
  ip = request.GET.get('ip', '')
205
  ipIn = ip_address.objects.filter(ip=ip).first()