main.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:legacy 作者: kytos 项目源码 文件源码
def save_topology(name):
        """Save a topology layout in a file.

        This method get a json topology from request and puts this in a file.

        Parameters:
            name (string): name of the topology to  be saved or loaded.

        Returns:
            topology (string): topology using json format.
        """
        if not request.is_json:
            return json.dumps('{"error": "gt was not a JSON request"}'), 400
        topology = request.get_json()
        with open(join(settings.TOPOLOGY_DIR, name + '.json'), 'w') as outfile:
            json.dump(topology, outfile)
        return json.dumps({'response': 'Saved'}), 201
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号