@app.route('/v' + API_VERSION + '/deployments', methods=['POST'])
def add_deployment():
    if not request.json and ('name' not in request.json or 'url' not in request.json):
        abort(400)
    name, url = request.json['name'], request.json['url']

    # Is there a deployment that's been registered with the specified url
    deployment = Deployment.by_url(url)
    if deployment is None:
        deployment = Deployment(name=name, url=url)
        deployment.save()
    else:
        return jsonify(deployment.as_dict())

    # Add the categories
    _post = request.json
    if 'categories' in _post:
        categories = []
        for cat in _post['categories']:
            category = Category(deployment_id=deployment.id,
                                origin_category_id=cat['origin_category_id'],
                                origin_parent_id=cat['origin_parent_id'],
                                title=cat['title'])
            categories.append(category)

        # Save the categories in bulk
        Category.create_all(categories)

    return jsonify(deployment.as_dict())
Registers a new Ushahidi deployment. The following information
dataset/ETHPy150Open dssg/ushine-learning/dssg/webapp/rest_api.py/add_deployment