python編寫接口這里用到的是他一個比較輕量級的框架 flask

#!/usr/bin/python
# -*- coding: UTF-8 -*-
import flask,json
server=flask.Flask(__name__)
@server.route('/index',methods=['get','post'])
def index():
res={'msg':'這是我開發的第一個借口','msg_code':0}
return json.dumps(res,ensure_ascii=False)
server.run(port=8888,debug=True,host='localhost')
然后執行python 文件名.py,
然后在瀏覽器端輸入http://localhost:8888/index