Git Product home page Git Product logo

nkust-ap-api's Introduction

Python 3.6

NKUST API Server(高雄科技大學 API Server)

Requirement

  • Ubuntu (18.04 or previous version)
  • Python 3.6
  • Redis server

API Docs

Quick start

Using Python virtual enviroment & Gunicorn

需要先在本地端設定/安裝好 Redis server

如果Redis有自行調整Host或Port或是使用外部的Redis,需執行

預設為本地的位置 redis://127.0.0.1:6379 執行

$ export REDIS_URL=redis://127.0.0.1:6666

若設定最新消息的管理員,可以透過;來新增多位管理員(非必須)

$ export NEWS_ADMIN="1106111111;1105293392"

或是設定一個帳號密碼,來登入管理員。

$ export NEWS_ADMIN_ACCOUNT="admin"
$ export NEWS_ADMIN_PASSWORD="1234567"

創建Python virtual enviroment

$ python3 -m venv venv

啟動 virtual enviroment

$ source venv/bin/activate

安裝相關packages

$ pip3 install -r requirement.txt

啟動伺服器(Debug 模式)

$ gunicorn web-server:app

啟動伺服器(Release 模式)

$ gunicorn -c gunicorn_config.py web-server:app

Using Docker-compose (Production Stage)

docker-compose中的docker image

$ cp env.example .env

如果有要設定最新消息的管理者,可以在.env中修改 NEWS_ADMIN 參數

REDIS_URL=redis://redis:6379

如需要更改redis位置,可以在.env中修改 REDIS_URL 參數,

這邊redis中的host是套用 dokcer network 的設定

REDIS_URL=redis://redis:6379

複製 nginx 設定檔(HTTPS)

$ cp nginx/nginx_nkust_api.conf.Example nginx/nginx_nkust_api.conf

若需要單純使用 HTTP 則需複製 nginx_nkust_api_http.conf.Example

$ cp nginx/nginx_nkust_api_http.conf.Example nginx/nginx_nkust_api.conf

nginx_nkust_api_http.conf 設定檔中 "所有"example.org取代為要目標的網域

2  server_name example.org;
...
17 server_name example.org;

更改為

2 server_name 目標網域;
...
17 server_name 目標網域;

註冊SSL憑證

修改init-letsencrypt.sh line 8~9 中的網域及email

8 domains=(aaa.example.org aaa.example.org)
9 email="[email protected]" 

給予shell sript 權限

$ sudo chmod +x init-letsencrypt.sh

並執行shell sript註冊,此過程會開啟伺服器

$ sudo ./init-letsencrypt.sh

後續再次開啟不需要使用init-letsencrypt.sh

最後執行docker-compose 開啟伺服器

-d 為背景執行,若不需要可以不用加

$ docker-compose up -d 

Other port

如有其他port 的需求

修改nginx/nginx_nkust_api.conf 像是一般的nginx設定檔案

nkust-ap-api's People

Contributors

abc873693 avatar dependabot[bot] avatar macs1207 avatar takidog avatar vn7n24fzkq avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.