示例#1
0
文件: api.py 项目: cholin/ff-ip-api
    def delete(self, address, prefixlen):
        network = Network.get(address, prefixlen).first_or_404()
        if network.owner != g.user:
            abort(401)

        db.session.delete(network)
        db.session.commit()
        return jsonify(message='success')
示例#2
0
文件: api.py 项目: cholin/ff-ip-api
    def get(self, address, prefixlen):
        if address is None or prefixlen is None:
            no_networks = request.args.get('no_networks', type=bool, default=False)
            networks = Network.get_all(no_networks = no_networks)
            return jsonify(networks=map(lambda n: n.as_dict(), networks))

        network = Network.get(address).first_or_404()
        return jsonify(network=network.as_dict(compact=False))
示例#3
0
文件: api.py 项目: cholin/ff-ip-api
    def put(self, address, prefixlen):
        network = Network.get(address, prefixlen).first_or_404()

        if 'address' in request.form:
            network.network_address = request.form['address']

        if 'prefixlen' in request.form:
            network.prefixlen = int(request.form['prefixlen'])

        db.session.commit()

        return jsonify(message='success')