Skip to content

a607ernie/Flask-uWSGI-Nginx-Docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask+uWSGI+Nginx+Docker Demo

目的&需求

  • 把一個Flask專案打包成docker
  • 需加上uWSGI & Nginx
  • 有時需要看nginx log 或是 uWSGI log , 因此需獨立出來(暫時的做法)

使用方法

  1. clone this repo
$ git clone https://github.com/a607ernie/Flask-uWSGI-Nginx-Docker
  1. run container
$ docker-compose up -d
  1. then call api

  2. close docker-compose

docker-compose down -v

測試用 API

http://localhost/

Python Flask in Docker!
A sample web-app for running Flask inside Docker.

API list :

[GET] /hi
[POST] /post_name

http://localhost/hi

hi

http://localhost/post_name

body

{
    "name":"json"
}

response

{
    "comment": "Hello json",
    "status": 200
}

資料夾結構

│  .dockerignore
│  app.ini
│  Dockerfile
│  requirements.txt
│  run.py
│  wsgi.py
│
├─app
│  │  __init__.py
│  │
│  ├─api
│  │  │  api_test.py
│  │  │
├─nginx
│  │  Dockerfile
│  │  flask_app.conf
│  │  nginx.conf
│  │
├─nginx_log
│  │  access.log
│  │  error.log
│  │
├─uwsgi_log
│  │  app.log
│  │

參考資料