-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
30 lines (24 loc) · 949 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import requests
import os
os.environ["no_proxy"] = "127.0.0.1"
if __name__ == "__main__":
# files = {"file": open("./test_files/TestPowerpoint.pptx", "rb")}
# files= {"file": open("./test_files/NotARealPowerpoint.pptx", "rb")}
# files= {"file": open("requirements.txt", "rb")}
files = {"file": open("tlas.pptx", "rb")}
resp = requests.post("http://127.0.0.1:5000/pptx-to-pdf", files=files)
if not resp.ok:
print(resp.text)
print(resp.status_code)
else:
with open("output.pdf", "wb") as f:
f.write(resp.content)
print(f"saved file as {os.path.join(os.getcwd(), 'output.pdf')}")
files = {"file": open("tlas.pptx", "rb")}
resp = requests.post("http://127.0.0.1:5000/extract-pptx-text", files=files)
if not resp.ok:
print(resp.text)
print(resp.status_code)
else:
print(f"Powerpoint contained text:\n{resp.text}")
print("done")