Spaces:
Sleeping
Sleeping
File size: 990 Bytes
73f2dea d420eb2 73f2dea d420eb2 73f2dea |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import gradio as gr
import json
def regions_list():
with open('regions.json', 'r') as f:
regions = json.load(f)
reg_name = [(i['name_uz'], i['id']) for i in regions]
reg_tuple = [tuple(reg_name[k]) for k in range(len(reg_name))]
return reg_tuple
def district_list():
with open('districts.json', 'r') as f:
districts = json.load(f)
dis_name = [(i['name_uz'], i['region_id']) for i in districts]
dis_tuple = [tuple(dis_name[k]) for k in range(len(dis_name))]
return dis_tuple
def get_district(reg_ch):
newDList = [i for i in district_list() if i[1]==reg_ch]
return dict(newDList)
with gr.Blocks() as iface:
gr.Markdown("""# Region lists""")
with gr.Row():
inp=gr.Dropdown(choices=regions_list(), label="Region")
out=gr.Label(label='Tanlovlar')
theme='gradio/seafoam'
inp.change(fn=get_district, inputs=inp, outputs=out)
if __name__=="__main__":
iface.launch(debug=True)
|