コード例 #1
0
ファイル: recipe.py プロジェクト: kvigen/cooking
def _delete_recipe(request, recipe_id):
   recipe_map = recipes.get_recipe_map()
   del recipe_map[recipe_id]
   recipes.save_recipe_map(recipe_map)
   filename = _get_recipe_filename(recipe_id)
   os.remove(filename)
   return HttpResponse("Success!")
コード例 #2
0
ファイル: recipe.py プロジェクト: kvigen/cooking
def _save_recipe(request, recipe_id):
  recipe_map = recipes.get_recipe_map()
  recipe = json.loads(request.body)
  recipe_map[recipe_id] = {"id": recipe["id"], "name": recipe["name"]};
  recipes.save_recipe_map(recipe_map)

  recipe_file = _get_recipe_filename(recipe_id)
  with open(recipe_file, "w+") as myfile:
    myfile.write(request.body)
  return HttpResponse("Success!")