Spaces:
Runtime error
Runtime error
updated url to stage
Browse files- playform.py +8 -6
playform.py
CHANGED
@@ -2,13 +2,14 @@
|
|
2 |
|
3 |
import functools
|
4 |
import requests
|
|
|
5 |
|
6 |
import io
|
7 |
import numpy
|
8 |
from PIL import Image
|
9 |
|
10 |
-
|
11 |
-
api_url_base = "http://
|
12 |
api_url_tail = "/generate/"
|
13 |
|
14 |
playform_load = """
|
@@ -56,13 +57,15 @@ def send_image(img,api_url,token):
|
|
56 |
|
57 |
print(api_url,token)
|
58 |
|
|
|
59 |
try:
|
60 |
response = requests.post(api_url,data=payload, headers=headers,files = files)
|
|
|
61 |
print("request sent")
|
62 |
print(response.text)
|
63 |
-
except:
|
64 |
-
print(
|
65 |
-
|
66 |
return
|
67 |
|
68 |
def playform(func):
|
@@ -105,7 +108,6 @@ def playform(func):
|
|
105 |
else:
|
106 |
print('unpredicted return type')
|
107 |
|
108 |
-
|
109 |
|
110 |
return ret_value
|
111 |
return wrapper_playform
|
|
|
2 |
|
3 |
import functools
|
4 |
import requests
|
5 |
+
from requests.exceptions import RequestException
|
6 |
|
7 |
import io
|
8 |
import numpy
|
9 |
from PIL import Image
|
10 |
|
11 |
+
# change this url to staging server or production server url
|
12 |
+
api_url_base = "http://stage.playform.io/api/app/projects/"
|
13 |
api_url_tail = "/generate/"
|
14 |
|
15 |
playform_load = """
|
|
|
57 |
|
58 |
print(api_url,token)
|
59 |
|
60 |
+
|
61 |
try:
|
62 |
response = requests.post(api_url,data=payload, headers=headers,files = files)
|
63 |
+
response.raise_for_status()
|
64 |
print("request sent")
|
65 |
print(response.text)
|
66 |
+
except RequestException as e:
|
67 |
+
print('Request failed:', e)
|
68 |
+
|
69 |
return
|
70 |
|
71 |
def playform(func):
|
|
|
108 |
else:
|
109 |
print('unpredicted return type')
|
110 |
|
|
|
111 |
|
112 |
return ret_value
|
113 |
return wrapper_playform
|