这几天一直在想,通过Serverless
Framework做一些什么事情,是有趣的,思前想后,决定做一个APICenter,基于腾讯云Serverless架构,使用Serverless
Framework只做一个API市场。
简单又愉快的,建立一个Project,全程将会用Python3.6进行开发。
![04fc0b2e91f4257fb36ac2db50a0b697.png](https://i-blog.csdnimg.cn/blog_migrate/2e481b740bd5ee020a84a2ba96086513.jpeg)
同时,我也会将这个系列的项目开源到
https://github.com/anycodes/ServerlessPracticehttp://github.com
废话不多说,先来第一个有趣的API,获取用户IP和IP地址,通过搜索引擎,我们可以查看到自己的IP地址:
![e90abfec6f3596f5773e8e0797a33ac8.png](https://i-blog.csdnimg.cn/blog_migrate/f2b818ea7736485098e9ce67d913e3c1.jpeg)
我们可以通过浏览器抓包,获得到这个请求的接口:
![ff1e4fc544520ead9bbfeee8b3de1266.png](https://i-blog.csdnimg.cn/blog_migrate/0e9d461e7c39803058f76a666f35c4e3.jpeg)
通过对接口的精简,可以确定,获取我的IP地址的请求链接就是:
https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?query=192.168.1.1&co=&resource_id=6006
接下来,我们可以通过Python编程来做这个功能:
# -*- coding:utf-8 -*-
import urllib.request
import json
import uuid
def return_msg(error, msg):
return_data = {
"uuid": str(uuid.uuid1()),