中移NB-lo模块AT指令使用HTTP协议发送数据到服务器。
//中移AT指令
//设置HTTP
AT+HTTPCREATE="http://IP:8080"
//设置协议头
AT+HTTPHEADER=0,"Content-Type:application/x-www-form-urlencoded"
//发送POST请求
AT+HTTPSEND=0,1,"/list?ceshi=123456789"
//关闭请求
AT+HTTPCLOSE=0
服务器python写的接收
import pymysql
from flask import Flask, request, jsonify
from flask_cors import CORS
#启动后端服务
app = Flask(__name__)
CORS(app, resources=r'/*')
@app.route('/list', methods=['POST'])
def login_list():
if request.method == "POST":
ceshi = request.values.get("ceshi")
# print(request.cookies)
try:
print(ceshi)
return "请求成功"
except Exception as e:
print("add a new user failed:",e)
db.rollback() #发生错误就回滚
return "请求失败"
#可创建多个路径请求
if __name__ == "__main__":
app.run(host='0.0.0.0',port=8080)
db.close()
print("Good bye!")