Spaces:
Runtime error
Runtime error
Download sapp.py from linpershey/process_mining: direct link, hf CLI and curl.
- Browser
- Download file 652 Bytes
-
https://huggingface.co/spaces/linpershey/process_mining/resolve/main/sapp.py
- Command line
-
hf download hf://spaces/linpershey/process_mining/sapp.py
-
curl -L -o sapp.py https://huggingface.co/spaces/linpershey/process_mining/resolve/main/sapp.py
652 Bytes
| import os | |
| import importlib | |
| import gradio as gr | |
| def greet(name): | |
| parent_name = get_process_name() | |
| return f"Hello {name}!! a greeting from {parent_name}" | |
| def get_process_name(): | |
| if importlib.util.find_spec("psutil"): | |
| import psutil | |
| parent_pid = os.getppid() | |
| try: | |
| parent_name = str(psutil.Process(parent_pid).name()) | |
| return parent_name | |
| except psutil.NoSuchProcess: # Catch the error caused by the process no longer existing | |
| print("NoSuchProcess") | |
| return "Uknown Process" | |
| if __name__ == "__main__": | |
| iface = gr.Interface(fn=greet, inputs="text", outputs="text") | |
| iface.launch() |