Last active
September 18, 2023 08:17
-
-
Save lgh06/40be91edc62e70b217dd785aaa1ed04d to your computer and use it in GitHub Desktop.
地址中省市县获取.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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