Download app.py from mmty/MP: direct link, hf CLI and curl.
- Browser
- Download file 782 Bytes
-
https://huggingface.co/spaces/mmty/MP/resolve/main/app.py
- Command line
-
hf download hf://spaces/mmty/MP/app.py
-
curl -L -o app.py https://huggingface.co/spaces/mmty/MP/resolve/main/app.py
782 Bytes
| import gradio as gr | |
| import os | |
| def play_media(media_file): | |
| os.system("mkdir uploads") | |
| file_path = os.path.join("uploads", media_file.name) | |
| with open(file_path, "wb") as file: | |
| file.write(media_file.data) | |
| return file_path | |
| def ui(): | |
| with gr.Blocks() as media_player: | |
| gr.Markdown("# Powerful Media Player") | |
| with gr.Tab("Upload"): | |
| with gr.Row(): | |
| media_file = gr.File(label="Upload Media") | |
| upload_button = gr.Button("Upload") | |
| with gr.Tab("Player"): | |
| with gr.Row(): | |
| media_display = gr.Video(label="Media Player") | |
| upload_button.click(play_media, inputs=media_file, outputs=media_display) | |
| return media_player | |
| media_player = ui() | |
| media_player.launch() |