bigghuggs commited on
Commit
b32c4c2
·
verified ·
1 Parent(s): b50db34

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -4
app.py CHANGED
@@ -1780,11 +1780,21 @@ def selectScript(evt: gr.SelectData, seshid):
1780
  valid_data = {'seshid':seshid, 'genuid': sesh.frmt_id_maps[sesh.current_img_signature][format]}
1781
  headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
1782
  start = time.time()
1783
- r = requests.post(url, data=json.dumps(valid_data), headers=headers)
1784
- jsondata = json.loads(r.content)
1785
- print('selectScript: ', format, time.time()-start, jsondata)
 
 
 
 
 
 
 
 
 
 
1786
  #return sesh.scripts[script]
1787
- return 'sesh.scripts[script]'
1788
 
1789
 
1790
 
 
1780
  valid_data = {'seshid':seshid, 'genuid': sesh.frmt_id_maps[sesh.current_img_signature][format]}
1781
  headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
1782
  start = time.time()
1783
+ #r = requests.post(url, data=json.dumps(valid_data), headers=headers)
1784
+ #jsondata = json.loads(r.content)
1785
+
1786
+ urls = ['https://dreamdemo.pythonanywhere.com/query_textgen' for i in range(1)]
1787
+ headers = [{'Content-type': 'application/json', 'Accept': 'text/plain'} for i in range(1)]
1788
+ json_data = [json.dumps({'seshid':seshid, 'genuid': sesh.frmt_id_maps[sesh.current_img_signature][format]}) for i in range(1)]
1789
+ responses = asyncio.run(main_post(urls, headers, json_data, timeout=.1))
1790
+ try:
1791
+ data_dict = json.loads(responses[0].content)
1792
+ except:
1793
+ data_dict = {}
1794
+
1795
+ print('selectScript: ', format, time.time()-start)
1796
  #return sesh.scripts[script]
1797
+ return 'Script being generated. Try again in 30 seconds.' if not data_dict or 'text' not in data_dict else data_dict['text']
1798
 
1799
 
1800