利用 Flask、Redis、MySQL 透過 RestFulAPI 的方式實現建立短網址、刪除、轉址的功能
-
直接使用
port預設為5000
py ./app.py
-
Docker Compose
透過docker-compose.yml的設定
已經把flask從port 5000轉發到port 80上
docker compose up
-
Create
curl -X POST -H "Content-type: application/json" -d '{"url":"https://www.facebook.com/","expireAt":"2024-08-30T09:20:41Z"}' 'http://localhost:port/api/v1/urls'
-
Redirect
curl -L -X GET -i http://localhost:port/3Lr6vWrIL9xBblu
-
Delete
curl -X DELETE -i http://localhost:port/api/v1/urls/3Lr6vWrIL9xBblu