lzghades commited on
Commit
18d1a6e
1 Parent(s): c7150f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -11,14 +11,14 @@ import gradio as gr
11
  import simplejson as json
12
  import oss2
13
 
14
- LOGGER = logging.getLogger('skybox')
15
- HANDLER = logging.handlers.RotatingFileHandler(
16
- './logs/skybox.log', mode='a', maxBytes=20 * 1000 * 1000, backupCount=5, encoding='utf-8')
17
- FORMATTER = logging.Formatter('%(asctime)s - %(funcName)s - %(lineno)d - %(levelname)s - %(message)s')
18
- HANDLER.setFormatter(FORMATTER)
19
- LOGGER.propagate = 0
20
- LOGGER.addHandler(HANDLER)
21
- LOGGER.setLevel(logging.DEBUG)
22
 
23
  CSS = '.gradio-container a {color:#b7adf4 !important}'
24
  HEADERS = {'app-key': os.environ['a3'], 'origin': os.environ['a4'], 'referer': os.environ['a4']}
@@ -33,7 +33,7 @@ def login(loginId, password):
33
  if resp.status_code == 200:
34
  return resp.json()['data']['token']
35
  except Exception as e:
36
- LOGGER.error(e)
37
  raise gr.Error('登录错误,请确认你的720yun账号是否正确')
38
 
39
 
@@ -46,7 +46,7 @@ def create_panorama(prompt, negative_prompt):
46
  'negative_text': negative_prompt.strip()[0:398]
47
  }
48
  resp = requests.post(os.environ['a1'], data=data)
49
- LOGGER.info(resp.text)
50
  if resp.status_code == 200:
51
  time.sleep(20)
52
  request_id = resp.json()['request']['id']
@@ -60,12 +60,12 @@ def create_panorama(prompt, negative_prompt):
60
  resp = requests.get(f'{os.environ["a1"]}/{request_id}?api_key={os.environ["a2"]}')
61
  if resp.status_code == 200:
62
  progress_data = resp.json()['request']
63
- if progress_data['progress'] == 100 and progress_data['status'] == 'complete':
64
  flag = False
65
  return request_id, progress_data['file_url']
66
  time.sleep(1)
67
  except Exception as e:
68
- LOGGER.error(e)
69
  raise gr.Error('AI老师罢工了,请稍后重试')
70
 
71
 
@@ -125,10 +125,11 @@ def upload(token, file_id, file_url):
125
  'source': 99
126
  }
127
  resp = requests.post(os.environ['a8'], data=data, headers=HEADERS)
 
128
  if resp.status_code == 200:
129
  return resp.json()['data']['tid']
130
  except Exception as e:
131
- LOGGER.error(e)
132
  raise gr.Error('AI老师罢工了,请稍后重试')
133
 
134
 
 
11
  import simplejson as json
12
  import oss2
13
 
14
+ # LOGGER = logging.getLogger('skybox')
15
+ # HANDLER = logging.handlers.RotatingFileHandler(
16
+ # './logs/skybox.log', mode='a', maxBytes=20 * 1000 * 1000, backupCount=5, encoding='utf-8')
17
+ # FORMATTER = logging.Formatter('%(asctime)s - %(funcName)s - %(lineno)d - %(levelname)s - %(message)s')
18
+ # HANDLER.setFormatter(FORMATTER)
19
+ # LOGGER.propagate = 0
20
+ # LOGGER.addHandler(HANDLER)
21
+ # LOGGER.setLevel(logging.DEBUG)
22
 
23
  CSS = '.gradio-container a {color:#b7adf4 !important}'
24
  HEADERS = {'app-key': os.environ['a3'], 'origin': os.environ['a4'], 'referer': os.environ['a4']}
 
33
  if resp.status_code == 200:
34
  return resp.json()['data']['token']
35
  except Exception as e:
36
+ # LOGGER.error(e)
37
  raise gr.Error('登录错误,请确认你的720yun账号是否正确')
38
 
39
 
 
46
  'negative_text': negative_prompt.strip()[0:398]
47
  }
48
  resp = requests.post(os.environ['a1'], data=data)
49
+ # LOGGER.info(resp.text)
50
  if resp.status_code == 200:
51
  time.sleep(20)
52
  request_id = resp.json()['request']['id']
 
60
  resp = requests.get(f'{os.environ["a1"]}/{request_id}?api_key={os.environ["a2"]}')
61
  if resp.status_code == 200:
62
  progress_data = resp.json()['request']
63
+ if progress_data['status'] == 'complete':
64
  flag = False
65
  return request_id, progress_data['file_url']
66
  time.sleep(1)
67
  except Exception as e:
68
+ # LOGGER.error(e)
69
  raise gr.Error('AI老师罢工了,请稍后重试')
70
 
71
 
 
125
  'source': 99
126
  }
127
  resp = requests.post(os.environ['a8'], data=data, headers=HEADERS)
128
+ # LOGGER.error(resp.text)
129
  if resp.status_code == 200:
130
  return resp.json()['data']['tid']
131
  except Exception as e:
132
+ # LOGGER.error(e)
133
  raise gr.Error('AI老师罢工了,请稍后重试')
134
 
135