Skip to content

Instantly share code, notes, and snippets.

@lgh06
Last active September 18, 2023 08:17
Show Gist options
  • Save lgh06/40be91edc62e70b217dd785aaa1ed04d to your computer and use it in GitHub Desktop.
Save lgh06/40be91edc62e70b217dd785aaa1ed04d to your computer and use it in GitHub Desktop.
地址中省市县获取.py
## pip install flask cpca
## http://172.24.1.55:8000/?keyword=福建省漳州市龙海市角美镇菜鸟电商园一期二号库夏奶录
import cpca
from flask import Flask,request
app = Flask(__name__)
@app.route('/',methods=["GET"])
def hello_world():
if request.method == "GET":
keyword = request.args.get("keyword")
# comment = request.values.get("content")
location_str = [keyword]
df = cpca.transform(location_str)
list = df.values.tolist()[0];
obj = df.to_dict();
return list;
return "error"
if __name__ == '__main__':
app.json.ensure_ascii = False
app.config['JSON_AS_ASCII'] = False
app.config['JSONIFY_MIMETYPE'] = "application/json;charset=utf-8"
app.run(port=8000, host='0.0.0.0')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment