需求
靠北我只有mac可以安裝pygraphviz
- 需安裝 pygraphviz,request
- 連上server(heroku or ngrok)
- pipenv等相關套件安裝
程式畫面
步驟
- 建立get_file.py,並打入程式碼
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15import requests
SERVER_IP = "0.0.0.0" #IP
API_SERVER = "http://" + SERVER_IP + ":8000" #port
DOWNLOAD_IMAGE_API = "/show-fsm"
try:
downloadImageInfoResponse = requests.get(
API_SERVER + DOWNLOAD_IMAGE_API)
if downloadImageInfoResponse.status_code == 200:
with open('img.jpg', 'wb') as getFile:
getFile.write(downloadImageInfoResponse.content)
except Exception as err:
print('Other error occurred %s' % {err}) - 在終端機輸入 pipenv run app.py
- 打開另一個終端機輸入pipenv run get_file.py
- 即可拿到生成的fsm圖
reference
【 Python 】透過 flask 中的 send_file 傳送影像