PurgeURL / app.py
rbughao's picture
Update app.py
94a097b verified
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()