# 部署一个查询ip的接口
1.创建服务
2.创建函数
3.vs code 上传代码
```js
const { Server } = require('@webserverless/fc-express')
const express = require('express');
const fs = require('fs');
const path = require('path');
const bodyParser = require('body-parser');
const searcher = require('node-ip2region').create();
const app = express();
app.get('\*', function(req, res) {
var ip = req.query.ip
if (ip == undefined) {
res.send({
"ip": null
})
return
}
var data = searcher.memorySearchSync(ip)
const { region } = data
var arr = region.split("|")
var redata = {
"country": arr\[0\] == "0" ? '' : arr\[0\],
"region": arr\[1\] == "0" ? '' : arr\[1\],
"province": arr\[2\] == "0" ? '' : arr\[2\],
"city": arr\[3\] == "0" ? '' : arr\[3\],
"isp": arr\[4\] == "0" ? '' : arr\[4\],
}
// \_城市Id|国家|区域|省份|城市|ISP\_
res.send(redata)
})
const server = newServer(app);
// http trigger entry
module.exports.handler = function(req, res, context) {
server.httpProxy(req, res, context);
};
```
# 如图

# 绑定域名
```
http://hkyun.rongyiapi.com/ipquery?ip=119.85.97.4
{"country": "中国","region": "","province": "重庆","city": "重庆市","isp": "电信"}
```

# 就是这么简单就创建好了一个函数了~