rbughao commited on
Commit
94a097b
1 Parent(s): 2e88643

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -3
app.py CHANGED
@@ -16,10 +16,28 @@ client = FastPurgeClient(
16
  }
17
  )
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  def reply(message, history):
20
- purged = client.purge_by_url([message])
21
- answer = str(purged.result())
22
- return answer
 
 
 
23
 
24
  Conversing = gr.ChatInterface(reply, chatbot=gr.Chatbot(height=600), retry_btn=None,theme=gr.themes.Monochrome(),
25
  title = 'Akamai Purge Cache', description = "Enter Brand.com URL for purging" ,undo_btn = None, clear_btn = None, css='footer {visibility: hidden}').launch()
 
16
  }
17
  )
18
 
19
+ def initialization():
20
+ client_secret = os.environ.get('client_secret')
21
+ host = os.environ.get('host')
22
+ access_token = os.environ.get('access_token')
23
+ client_token = os.environ.get('client_token')
24
+ client = FastPurgeClient(
25
+ auth={
26
+ "client_secret": client_secret ,
27
+ "host": host,
28
+ "access_token": access_token,
29
+ "client_token": client_token
30
+ }
31
+ )
32
+
33
+
34
  def reply(message, history):
35
+ if message == 'initialize':
36
+ initialization()
37
+ return 'Application re-initialized'
38
+ purged = client.purge_by_url([message])
39
+ answer = str(purged.result())
40
+ return answer
41
 
42
  Conversing = gr.ChatInterface(reply, chatbot=gr.Chatbot(height=600), retry_btn=None,theme=gr.themes.Monochrome(),
43
  title = 'Akamai Purge Cache', description = "Enter Brand.com URL for purging" ,undo_btn = None, clear_btn = None, css='footer {visibility: hidden}').launch()