Dingyi6 commited on
Commit
3656a48
·
1 Parent(s): 1e82c6e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -13
app.py CHANGED
@@ -7,22 +7,12 @@ import io
7
  parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
8
  sys.path.append(parent_dir)
9
 
 
 
 
10
  import ee
11
  # ee.Authenticate()
12
 
13
- current_path = os.getcwd()
14
- full_path = os.path.join(current_path, 'ee-yudingyi054-64e93ae89dc1.json')
15
- # Add Google Service account credential. Authenticates to the Earth Engine servers.
16
- os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = full_path
17
-
18
- if 'GOOGLE_APPLICATION_CREDENTIALS' in os.environ:
19
- print("GOOGLE_APPLICATION_CREDENTIALS set to:", os.environ['GOOGLE_APPLICATION_CREDENTIALS'])
20
- else:
21
- print("GOOGLE_APPLICATION_CREDENTIALS is not set")
22
-
23
- # Initialize Earth Engine
24
- ee.Initialize()
25
-
26
  import math
27
  from shiny import App, render, ui, reactive, Inputs, Outputs, Session
28
  import ipyleaflet as L
@@ -215,6 +205,9 @@ app_ui = ui.page_fluid(
215
 
216
  # re-run when a user using the application
217
  def server(input, output, session):
 
 
 
218
  global address_line, polygoned_image
219
  address_line = None
220
  polygoned_image = None
 
7
  parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
8
  sys.path.append(parent_dir)
9
 
10
+ service_account = 'earthengine@ee-yudingyi054.iam.gserviceaccount.com'
11
+ credentials = ee.ServiceAccountCredentials(service_account, 'ee-yudingyi054-64e93ae89dc1.json')
12
+
13
  import ee
14
  # ee.Authenticate()
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  import math
17
  from shiny import App, render, ui, reactive, Inputs, Outputs, Session
18
  import ipyleaflet as L
 
205
 
206
  # re-run when a user using the application
207
  def server(input, output, session):
208
+ # Initialize Earth Engine
209
+ ee.Initialize(credentials)
210
+
211
  global address_line, polygoned_image
212
  address_line = None
213
  polygoned_image = None