Python

Python

linux 安装

源码编译

1
2
3
4
5
6
curl -o [filename] [url]
tar -[z]xvf *.tar.xz
/usr/local/src/
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make

build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev

依赖项

1
gcc zlib zlib1g-dev bz2

API Server

flask 框架, 安装flask-cors

1
2
pip install flask
pip install flask-cors
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
from flask import Flask, request
from flask_cors import CORS, cross_origin

app = Flask(__name__)
CORS(app, supports_credentials=True) // 全局跨域

@app.route('/api/dyson')
# @cross_origin(supports_credentials=True) // 部分路由跨域
def index():
    return {'name': 'dyson', 'msg': 'Hello Python!'}

if __name__ == '__main__':
    app.run()
Licensed under CC BY-NC-SA 4.0
最后更新于 Aug 14, 2024 09:43 UTC