Giter Club home page Giter Club logo

e-resepti's Introduction

E-Resepti

E-resepti is a CLI and REST application for managing recipes.

To begin, create the virtualenv and enter it:

$ virtualenv env -p $(which python3)
$ source env/bin/activate

Then, install the dependencies:

(env) $ pip install -r requirements.txt`

Command-line interface

The file e-resepti.py can be executed, with a command (and parameters) as its parameters. The script reads the recipes from a recipes.json file in its working directory. Before modifying the recipes.json file, the script creates a backup file containing the current contents at .recipes.json.backup. The command can be:

list

Lists the names of all the recipes in the book.

read <index>

Prints out a recipe, formatted for reading.

add

Read a recipe in JSON format (see below) from stdin and add it to the recipe book.

Hint: if you want to type the JSON at the terminal, you can do the following:

$ python e-resepti.py add <<EOF
> /* type recipe JSON here */
> EOF
New recipe added!
$

delete <index>

Deletes a recipe from the recipe book.

REST API

The file e-resepti.py is also a Flask app that serves a REST API for managing the recipe book.

(env) $ FLASK_APP=e-resepti.py flask run

The endpoints served are:

GET /recipes

[Recipe]

Returns a list of all recipes in JSON format (see below).

GET /recipes/{index}

Recipe

Returns one recipe (indexed by the order returned in GET /recipes)

GET /recipes/filter?ingredient={ingredient}

[Recipe]

Returns all recipes where some ingredient matches the supplied search term.

POST /recipes

Adds a new recipe to the recipe book (body in JSON format).

DELETE /recipes/{index}

Deletes recipe from recipe book

JSON data models

Recipe

name (String): Name of the recipe

ingredients ([Ingredient]): Ingredients required for the recipe

instructions (String): Instructions for how to complete the recipe

Ingredient

amount (Number): amount of ingredient

unit (String): unit of the amount

name (String): name of the ingredient

e-resepti's People

Contributors

vurpo avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.