Upload 4 files
Browse files- Dockerfile +18 -0
- README.md +15 -10
- app.py +1 -1
- requirements.txt +1 -0
Dockerfile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 基礎映像:Python 3.9
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
+
|
| 4 |
+
# 設定工作目錄
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# 複製所需檔案
|
| 8 |
+
COPY requirements.txt .
|
| 9 |
+
COPY app.py .
|
| 10 |
+
|
| 11 |
+
# 安裝依賴
|
| 12 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 13 |
+
|
| 14 |
+
# 指定埠口
|
| 15 |
+
EXPOSE 5000
|
| 16 |
+
|
| 17 |
+
# 啟動應用
|
| 18 |
+
CMD ["python", "app.py"]
|
README.md
CHANGED
|
@@ -1,10 +1,15 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Flask Command Server
|
| 2 |
+
|
| 3 |
+
一個簡單的 Flask 應用,透過 `/set_command` 設定指令,並從 `/get_command` 取得目前指令。
|
| 4 |
+
|
| 5 |
+
## API
|
| 6 |
+
|
| 7 |
+
### POST /set_command
|
| 8 |
+
```json
|
| 9 |
+
{ "command": "your_command" }
|
| 10 |
+
```
|
| 11 |
+
|
| 12 |
+
### GET /get_command
|
| 13 |
+
```json
|
| 14 |
+
{ "command": "your_command" }
|
| 15 |
+
```
|
app.py
CHANGED
|
@@ -14,4 +14,4 @@ def get_command():
|
|
| 14 |
return {"command": command}
|
| 15 |
|
| 16 |
if __name__ == "__main__":
|
| 17 |
-
app.run(host="0.0.0.0", port=5000)
|
|
|
|
| 14 |
return {"command": command}
|
| 15 |
|
| 16 |
if __name__ == "__main__":
|
| 17 |
+
app.run(host="0.0.0.0", port=5000)
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
flask
|