Menu

Tree [33874b] master /
 History

HTTPS access


File Date Author Commit
 docs 2020-07-15 hzf hzf [4eca28] update doc
 scripts 2020-06-19 Allen Shaw Allen Shaw [06e262] ✨ add gunicorn and logging config files
 temp_api 2020-07-16 Allen Shaw Allen Shaw [5e6fc5] 🚑 make tevent count as remained for hs, mx, and my
 tests 2020-07-16 Allen Shaw Allen Shaw [33874b] ✅ update test cases
 .dockerignore 2020-06-12 Allen Shaw Allen Shaw [94d66b] ➕ add distribution folder
 .env 2020-03-27 Allen Shaw Allen Shaw [f14b63] Initial commit
 .gitignore 2020-06-12 Allen Shaw Allen Shaw [cfdff4] 🔥 remove repeated patterns
 .gitlab-ci.yml 2020-05-23 Allen Shaw Allen Shaw [f5eb14] docs: add .gitlab-ci.yml
 CHANGELOG.md 2020-06-11 Allen Shaw Allen Shaw [2dba1a] 📝 update readme and changelog
 Dockerfile 2020-06-20 Allen Shaw Allen Shaw [efe205] 🔥 remove requirements archives after installing
 Pipfile 2020-04-28 Allen Shaw Allen Shaw [d96fe7] test: add tests depends
 Pipfile.lock 2020-04-28 Allen Shaw Allen Shaw [d96fe7] test: add tests depends
 README.md 2020-07-14 Allen Shaw Allen Shaw [a2658b] ✅ test all APIs in one step
 gunicorn_config.py 2020-06-20 Allen Shaw Allen Shaw [6ef69a] ✨ add request time to log
 logging.conf 2020-07-02 Allen Shaw Allen Shaw [2ee511] 💡 add comments in source code
 main.py 2020-07-02 Allen Shaw Allen Shaw [2ee511] 💡 add comments in source code
 requirements.txt 2020-04-28 Allen Shaw Allen Shaw [d96fe7] test: add tests depends

Read Me

Temperature API

A flask api app for temperature platform based on flask-restful.

Environment

  • Python 3.6 or later

Development manual

1. Clone

$ git clone http://10.161.32.68/F1054460/temp-api.git

2. Run flask app with pipenv

$ cd temp-api/
$ pipenv install
$ pipenv shell

$ export FLASK_CONFIG=development
$ flask run -h 0.0.0.0 -p 5000 --reload

Deployment

⚠️ Before deployment, confirm the configuration for different campuses. To switch campus, just edit CAMPUS_ID in file config.py, available parameters:

  • 1 : Longhua
  • 2 : Wuhan
  • 3 : Chongqing
  • 4 : Huasheng
  • 5 : Mexico
  • 6 : Malaysia

Automatic deployment

$ sudo chmod +x scripts/deploy.sh

$ ./scripts/deploy.sh

Manual deployment

1. Build docker image

$ docker build -t temp-api:latest -f Dockerfile .

2. Export the built image

$ docker save -o temp-api_latest.tar.gz

3. Send the image file to remote

$ rsync temp-api_latest.tar.gz USER@HOST:PORT:/PATH/TO/DIR

4. Load image from file (on remote server)

$ ssh USER@HOST:PORT

$ docker load -i /PATH/TO/DIR/temp-api_latest.tar.gz

5. Run for production

$ docker run -d -p 5857:5000 --env FLASK_CONFIG=production --restart always --name temp-api temp-api:latest

API

  • Documentation
  • Quick test:
    • Open Postman, then import collection from file: tests/temp-api_test-cases-for-Longhua.postman_collection.json
    • Run the collection, test cases should be 100% passed (only for Longhua).

Change Log

CHANGELOG

Authors