python编写接口初识一
生活随笔
收集整理的這篇文章主要介紹了
python编写接口初识一
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
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':'這是我開發(fā)的第一個借口','msg_code':0}return json.dumps(res,ensure_ascii=False)server.run(port=8888,debug=True,host='localhost') View Code然后執(zhí)行python 文件名.py,
然后在瀏覽器端輸入http://localhost:8888/index
?
轉(zhuǎn)載于:https://www.cnblogs.com/ldlx-mars/p/10636691.html
總結(jié)
以上是生活随笔為你收集整理的python编写接口初识一的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JS自定义字符串格式化函数
- 下一篇: Python基础之二进制