Spaces:
Sleeping
Sleeping
Update src/pyscripts/run.py
Browse files- src/pyscripts/run.py +22 -3
src/pyscripts/run.py
CHANGED
|
@@ -136,6 +136,24 @@ def getConferencePoster(item: ConferencePosterInfo):
|
|
| 136 |
file_url = f"https://pub-429c75a96a8f4597984dd7ebc525d652.r2.dev/{object_name}"
|
| 137 |
return {"url": file_url}
|
| 138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
|
| 141 |
interface = gr.Interface(lambda x: "Hello, " + x + "!", "textbox", "textbox")
|
|
@@ -143,9 +161,10 @@ app = gr.mount_gradio_app(app, interface, path=CUSTOM_PATH)
|
|
| 143 |
|
| 144 |
|
| 145 |
if __name__ == "__main__":
|
| 146 |
-
MOCK_URL = "https://mock.jsont.run/
|
| 147 |
res = requests.get(MOCK_URL)
|
| 148 |
mock_data = res.json()
|
|
|
|
| 149 |
print(mock_data)
|
| 150 |
-
|
| 151 |
-
|
|
|
|
| 136 |
file_url = f"https://pub-429c75a96a8f4597984dd7ebc525d652.r2.dev/{object_name}"
|
| 137 |
return {"url": file_url}
|
| 138 |
|
| 139 |
+
@app.post("/getGuestComposePoster")
|
| 140 |
+
def getGuestComposePoster(item):
|
| 141 |
+
# item.conference_rundown = [list(i) for i in item.conference_rundown]
|
| 142 |
+
sorted_conference_guest = sorted(item["guest"], key=lambda x: x['rank'])
|
| 143 |
+
img_stream = img_process.getGuestComposePoster(
|
| 144 |
+
item["name"],
|
| 145 |
+
item["eng_name"],
|
| 146 |
+
sorted_conference_guest)
|
| 147 |
+
file_dir = "ConferencePoster"
|
| 148 |
+
object_name = file_dir + "/" + item["name"] + ".jpg"
|
| 149 |
+
if os.path.exists("src/assets/output"):
|
| 150 |
+
with open(f"src/assets/output/{item['name'] + '.jpg'}", 'wb') as f:
|
| 151 |
+
f.write(img_stream.getvalue())
|
| 152 |
+
else:
|
| 153 |
+
oss.upload_file_stream_to_s3(img_stream, "host", object_name)
|
| 154 |
+
file_url = f"https://pub-429c75a96a8f4597984dd7ebc525d652.r2.dev/{object_name}"
|
| 155 |
+
return {"url": file_url}
|
| 156 |
+
|
| 157 |
|
| 158 |
|
| 159 |
interface = gr.Interface(lambda x: "Hello, " + x + "!", "textbox", "textbox")
|
|
|
|
| 161 |
|
| 162 |
|
| 163 |
if __name__ == "__main__":
|
| 164 |
+
MOCK_URL = "https://mock.jsont.run/iKAdks2DIVBtx-R7Fbw3y"
|
| 165 |
res = requests.get(MOCK_URL)
|
| 166 |
mock_data = res.json()
|
| 167 |
+
# mock_data = ConferencePosterInfo(**mock_data)
|
| 168 |
print(mock_data)
|
| 169 |
+
# getConferencePoster(mock_data)
|
| 170 |
+
getGuestComposePoster(mock_data["conference_info"])
|