Download app.py from sdlf/new_1: direct link, hf CLI and curl.
- Browser
- Download file 837 Bytes
-
https://huggingface.co/spaces/sdlf/new_1/resolve/main/app.py
- Command line
-
hf download hf://spaces/sdlf/new_1/app.py
-
curl -L -o app.py https://huggingface.co/spaces/sdlf/new_1/resolve/main/app.py
837 Bytes
| import pandas as pd | |
| import gradio as gr | |
| import requests | |
| # Function to display the DataFrame | |
| def display_table(query): | |
| res = requests.get(f'http://13.232.212.105:5002/search_mcat_prime/?k=20&kw={query}&modid=extract').json() | |
| res = pd.DataFrame(res['results']) | |
| res = res.rename(columns={'Position':'RANK','Score':'SCORE','glcat_mcat_id':'MCAT_ID','glcat_mcat_name':'MCAT_NAME'}) | |
| res = res[['RANK','MCAT_ID','MCAT_NAME','SCORE']] | |
| return res | |
| # Setup Gradio interface | |
| with gr.Blocks() as demo: | |
| query_input = gr.Textbox(label="Enter your query") | |
| submit_btn = gr.Button("Submit Query") | |
| output_table = gr.Dataframe() | |
| submit_btn.click(fn=display_table, inputs=query_input, outputs=output_table) | |
| if __name__ == "__main__": | |
| demo.launch(share=False,inbrowser=False, server_name="0.0.0.0", server_port=5004) |