def post(self):
        """**Create a Host entry**

        **Example Request:**

        .. sourcecode:: http

            POST /api/v1/hosts HTTP/1.1
            Host: localhost
            Content-Type: application/json
            {
                "hostname": "example"
            }

        or:

        .. sourcecode:: http

            {
                "hosts": [
                    {
                        "hostname": "server1"
                    },
                    {
                        "hostname": "server2"
                    },
                    ...
                ]
            }

        **Example response:**

        .. sourcecode:: http

            HTTP/1.1 201 OK
            Location: /api/v1/hosts/example

            {
                "status": "created",
                "href": "/api/v1/hosts/example",
                "id": 1,
                "hostname": "example"
            }

        or:

        .. sourcecode: http

            {
                "status": "created",
                "hosts":
                [
                    {
                        "href": "/api/v1/hosts/testserver1",
                        "hostname": "testserver1",
                        "id": 42
                    },
                    {
                        "href": "/api/v1/hosts/testserver2",
                        "hostname": "testserver2",
                        "id": 43
                    },
                    {
                        "href": "/api/v1/hosts/testserver3",
                        "hostname": "testserver3",
                        "id": 44
                    }
                ],
                "totalHosts": 3
            }

        :reqjson string hostname: The hostname of the server

        :reqheader Content-Type: The server expects a json body specified with
                                 this header.

        :resheader Location: URL to the created resource.

        :statuscode 201: The Host was successfully created.
        :statuscode 400: The request was malformed.
        :statuscode 401: The request was made without being logged in.
        :statuscode 409: There was a conflict with another resource.
        """

        try:
            if "hosts" in self.jbody:
                hostnames = self.jbody["hosts"]
            else:
                hostnames = [{"hostname": self.jbody["hostname"]}]
        except KeyError as err:
            raise exc.BadRequest(
                "Missing Required Argument: {}".format(err.message)
            )
        except ValueError as err:
            raise exc.BadRequest(err.message)

        log.info("HOSTS: Create {}".format(", ".join(
            [
                host["hostname"] for host in hostnames
            ]
        )))

        try:
            hosts = []
            for hostname in hostnames:
                host = Host.create(self.session, hostname["hostname"])
                hosts.append(host.to_dict(self.href_prefix))
        except IntegrityError as err:
            raise exc.Conflict(err.orig.message)
        except exc.ValidationError as err:
            raise exc.BadRequest(err.message)

        self.session.commit()

        if len(hosts) == 1:
            json = hosts[0]
            self.created("/api/v1/hosts/{}".format(hosts[0]["hostname"]), json)
        else:
            self.created(data={"hosts": hosts, "totalHosts": len(hosts)})

        log.info("HOST: Created {}".format(", ".join(
            [host["hostname"] for host in hostnames]
        )))
dataset/ETHPy150Open dropbox/hermes/hermes/handlers/api.py/HostsHandler.post/original