File size: 1,429 Bytes
2ed84e2
2e88643
174330a
 
2e88643
 
 
 
 
174330a
 
2e88643
 
 
 
174330a
 
2ed84e2
94a097b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a367380
94a097b
 
 
 
 
 
2ed84e2
a367380
 
2ed84e2
 
a367380
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import gradio as gr
import os
from fastpurge import FastPurgeClient

client_secret =  os.environ.get('client_secret')
host =  os.environ.get('host')
access_token =  os.environ.get('access_token')
client_token =  os.environ.get('client_token')

client = FastPurgeClient(
    auth={
        "client_secret": client_secret ,
        "host": host,
        "access_token": access_token,
        "client_token": client_token
        }
    )

def initialization():
    client_secret =  os.environ.get('client_secret')
    host =  os.environ.get('host')
    access_token =  os.environ.get('access_token')
    client_token =  os.environ.get('client_token')
    client = FastPurgeClient(
    auth={
        "client_secret": client_secret ,
        "host": host,
        "access_token": access_token,
        "client_token": client_token
        }
    )
    

def reply(message, history):
    if message == 'initialize':
        initialization()
        return 'Application re-initialized'
    purged = client.purge_by_url([message])
    answer = str(purged.result())
    return answer

Conversing = gr.ChatInterface(reply, chatbot=gr.Chatbot(height=600), retry_btn=None,theme=gr.themes.Monochrome(),
                              title = 'Akamai Purge Cache', description = "Enter Brand.com URL for purging" ,undo_btn = None, clear_btn = None, css='footer {visibility: hidden}').launch()

if __name__ == "__main__":
    Conversing.launch()