Code Monkey home page Code Monkey logo

api-server's Introduction

wuhan2020-api-server

武汉新型冠状病毒防疫信息收集平台后端

快速上手

git clone https://github.com/wuhan2020/api-server
cd api-server
git clone https://github.com/wuhan2020/wuhan2020
pip install -r requirements.txt
bash bootstrap

然后就可以在http://your-ip:9000/wuhan2020/调试api 注意list_path是在utils.py中被data.route注册的path, your-ip默认是127.0.0.1

Docker 容器运行

需要安装Docker客户端.

Build Docker Image

在本项目根目录下执行 docker build -t api-server:default .. 注意国内这一步可能会耗时较长.

Run Docker Image

执行 docker run --name api-server --publish 5000:5000 api-server:default 后可在本地浏览器中打开http://localhost:5000/wuhan2020/{endpoint}. (使用 -d 进入detach模式)

如果出现 The container name "/api-server" is already in use 报错可先执行 docker rm api-server 删除残留的同名容器.

Stop Docker Container

执行 docker stop api-server 停止运行中的容器.

项目文件说明

.
├── bootstrap(阿里云serverless启动脚本)
├── index.py(flask应用默认配置脚本)
└── utils.py(flask蓝图功能)

index.py说明

# -*- coding: utf-8 -*-
from flask import  Flask,session,request,Blueprint
import os
import sys
import json
import platform
import datetime
from utils import data

app = Flask(__name__)
app.debug = True
# 默认开启debug
path_prefix= "/wuhan2020"
# url请求前缀,默认要加/wuhan2020
if platform.system()=="Linux":
    path_home="/home/wuhan2020/wuhan2020"
else:
    path_home=os.path.join(app.root_path,"wuhan2020")
# 阿里云serverless使用挂载nas远程目录来存放缓存文件
# 在本机调试时,缓存文件夹将存放在项目根目录
if not os.path.exists(path_home):
    os.mkdir(path_home)
app.register_blueprint(data, url_prefix=path_prefix)
#使用flask蓝图功能来注册http-router

if __name__ == '__main__':
    # 使用aliyun默认端口9000
    port = os.environ.get("FC_SERVER_PORT", "9000")
    app.run(host='127.0.0.1', port=int(port))

前端项目issues

https://github.com/wuhan2020/front-pages/issues

api-server's People

Contributors

frank-zsy avatar icearn avatar jamesbonddu avatar letshan avatar liuchangfreeman avatar rexwangcc avatar songyu-wang avatar zzszmyf 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.