究竟还是到了让我个前端新人自个儿写接口的时候,撸起袖子间接上代码
import pymssql
import time
from flask import Flask, request, jsonify
from flask_cors import CORS
# 数据库连贯
db = pymssql.connect(host='本人的数据库地址',
user='用户名',
password='明码',
database='数据库名')
cursor = db.cursor()
# 后端服务启动
app = Flask(__name__)
CORS(app, resources=r'/*')
# 接口
@app.route('/myGET', methods=['GET'])
def my_get():
if request.method == "GET":
# 业务逻辑
···
# 业务实现记得断开数据库连贯
if __name__ == "__main__":
app.run(host='0.0.0.0', port=8888)
db.close()
print("good bye")