import gradio as gr def greet(Batch, file): import re # with open(file, encoding = 'utf-8') as f: placed = set() print(file) file.seek(0) cont = file.read() print(cont) chat = re.split('../../.., *', cont.decode('utf-8')) for msg in chat: if 'acceptance' in msg: print(re.findall(': (.)FTE',msg), sorted(re.findall('(?i)2k19/co/[0-9]',msg))) placed.update(re.findall(f'(?i){Batch}/[0-9]*', msg)) return str(len(placed)) demo = gr.Interface(fn=greet, inputs=["text", "file"], outputs="text") demo.launch()