Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -509,7 +509,7 @@ def updateItemDisplay(seshid, budget=False):
|
|
| 509 |
data = sesh.__dict__
|
| 510 |
valid_data = {k:v for k,v in data.items() if k in keys and isJSONSerialiazable(v)}
|
| 511 |
print('updateItemDisplay sesh keys: ', valid_data.keys())
|
| 512 |
-
|
| 513 |
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
| 514 |
|
| 515 |
if True: #try:
|
|
@@ -521,6 +521,7 @@ def updateItemDisplay(seshid, budget=False):
|
|
| 521 |
print('json return status code: ', r.status_code)
|
| 522 |
data_dict = json.loads(r.content)
|
| 523 |
for k in data_dict:
|
|
|
|
| 524 |
print('setting attr: ', k)
|
| 525 |
setattr(sesh, k, data_dict[k])
|
| 526 |
|
|
@@ -782,7 +783,7 @@ def makePalettes(evt: gr.SelectData, seshid):
|
|
| 782 |
#print('makePalettes: ', type(evt.value), evt.value)
|
| 783 |
sesh.img_id = sesh.current_img_signature = evt.value['caption'] if evt.value['caption'] else sesh.current_img_signature
|
| 784 |
if sesh.current_img_signature in sesh.Palettes_displayed:
|
| 785 |
-
display = updateItemDisplay(
|
| 786 |
return sesh.Palettes_displayed[sesh.current_img_signature], sesh.img_data[sesh.current_img_signature], display
|
| 787 |
|
| 788 |
img = sesh.img_data[sesh.img_id]
|
|
@@ -808,8 +809,8 @@ def makePalettes(evt: gr.SelectData, seshid):
|
|
| 808 |
#print('bestclr_keys: ', bestclr_keys)
|
| 809 |
url = 'https://dreamdemo.pythonanywhere.com/palletes'
|
| 810 |
#valid_data = {'seshid': str(sesh.seshid), 'img_id':str(sesh.img_id), 'dark_light_bool':str(dark_light_bool), 'bestclr_keys':bestclr_keys}
|
| 811 |
-
valid_data = {'seshid': str(sesh.seshid), 'img_id':str(sesh.img_id), 'dark_light_bool':str(dark_light_bool), 'counts_srtd_rgb':counts_srtd_rgb}
|
| 812 |
-
|
| 813 |
print('MAKE PALLETE SESHID: ', seshid, sesh.seshid)
|
| 814 |
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
| 815 |
#print('json requests response: ', str({k:(type(v), None if type(v) != type(dict({})) or not v else (type(list(v.items())[0][0]), type(list(v.items())[0][1]))) for k,v in valid_data.items()}))
|
|
@@ -891,7 +892,7 @@ def makePalettes(evt: gr.SelectData, seshid):
|
|
| 891 |
sesh.Palette_img[150:,:] = palettes_data[0][3]
|
| 892 |
|
| 893 |
sesh.Palette_imgs[sesh.img_id] = sesh.Palette_img
|
| 894 |
-
display = updateItemDisplay(
|
| 895 |
|
| 896 |
sesh.Palettes_displayed[sesh.current_img_signature] = Palette_out
|
| 897 |
|
|
|
|
| 509 |
data = sesh.__dict__
|
| 510 |
valid_data = {k:v for k,v in data.items() if k in keys and isJSONSerialiazable(v)}
|
| 511 |
print('updateItemDisplay sesh keys: ', valid_data.keys())
|
| 512 |
+
valid_data['seshid'] = seshid
|
| 513 |
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
| 514 |
|
| 515 |
if True: #try:
|
|
|
|
| 521 |
print('json return status code: ', r.status_code)
|
| 522 |
data_dict = json.loads(r.content)
|
| 523 |
for k in data_dict:
|
| 524 |
+
if k == 'seshid': continue
|
| 525 |
print('setting attr: ', k)
|
| 526 |
setattr(sesh, k, data_dict[k])
|
| 527 |
|
|
|
|
| 783 |
#print('makePalettes: ', type(evt.value), evt.value)
|
| 784 |
sesh.img_id = sesh.current_img_signature = evt.value['caption'] if evt.value['caption'] else sesh.current_img_signature
|
| 785 |
if sesh.current_img_signature in sesh.Palettes_displayed:
|
| 786 |
+
display = updateItemDisplay(seshid)
|
| 787 |
return sesh.Palettes_displayed[sesh.current_img_signature], sesh.img_data[sesh.current_img_signature], display
|
| 788 |
|
| 789 |
img = sesh.img_data[sesh.img_id]
|
|
|
|
| 809 |
#print('bestclr_keys: ', bestclr_keys)
|
| 810 |
url = 'https://dreamdemo.pythonanywhere.com/palletes'
|
| 811 |
#valid_data = {'seshid': str(sesh.seshid), 'img_id':str(sesh.img_id), 'dark_light_bool':str(dark_light_bool), 'bestclr_keys':bestclr_keys}
|
| 812 |
+
#valid_data = {'seshid': str(sesh.seshid), 'img_id':str(sesh.img_id), 'dark_light_bool':str(dark_light_bool), 'counts_srtd_rgb':counts_srtd_rgb}
|
| 813 |
+
valid_data = {'seshid': str(seshid), 'img_id':str(sesh.img_id), 'dark_light_bool':str(dark_light_bool), 'counts_srtd_rgb':counts_srtd_rgb}
|
| 814 |
print('MAKE PALLETE SESHID: ', seshid, sesh.seshid)
|
| 815 |
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
|
| 816 |
#print('json requests response: ', str({k:(type(v), None if type(v) != type(dict({})) or not v else (type(list(v.items())[0][0]), type(list(v.items())[0][1]))) for k,v in valid_data.items()}))
|
|
|
|
| 892 |
sesh.Palette_img[150:,:] = palettes_data[0][3]
|
| 893 |
|
| 894 |
sesh.Palette_imgs[sesh.img_id] = sesh.Palette_img
|
| 895 |
+
display = updateItemDisplay(seshid)
|
| 896 |
|
| 897 |
sesh.Palettes_displayed[sesh.current_img_signature] = Palette_out
|
| 898 |
|