Skip to content

Instantly share code, notes, and snippets.

@atomize
Created October 30, 2019 16:55
Show Gist options
  • Save atomize/278b578bf79751cc03203606847432bb to your computer and use it in GitHub Desktop.
Save atomize/278b578bf79751cc03203606847432bb to your computer and use it in GitHub Desktop.
from flask import Flask, jsonify, request
from flask_cors import CORS
import usaddress
app = Flask(__name__)
CORS(app)
def addressmaker(inputarr):
newarr = []
for x in inputarr:
newarr.append(usaddress.tag(x))
return newarr
@app.route('/address', methods=['POST'])
def postJsonHandler():
req = request.get_json()['data']
return_object = usaddress.tag(req) if type(req) is str else addressmaker(req)
return jsonify(return_object)
if __name__ == '__main__':
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment