<s>[INST] # Recipe Book App

### Description:
A simple full-stack web application that allows users to add, edit, and delete their favorite recipes. This app will be created using Flask in the back-end and HTML/CSS in the front-end.

---

### Database schema:
We use a simple relational database with two tables.

- **recipes**
  - **id** (int): Unique identifier for recipe
  - **name** (str): Recipe name
  - **description** (text): Brief description of the recipe
  - **ingredients** (text): List of ingredients needed for recipe
  - **instructions** (text): Instructions for cooking the recipe

### Notes:
- We will be using Flask-SQLAlchemy for ORM and create a database using sqlite for this project.
- Every model is represented as a class in our application.
- The API will be stateless - no user registration required.

---

### Code Snippet 1: Models
```python
from app import db


# Recipe model
class Recipe(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), index=True, unique=True)
    description = db.Column(db.Text)
    ingredients = db.Column(db.Text)
    instructions = db.Column(db.Text)

    def __repr__(self):
        return '<Recipe {}>'.format(self.name)
```

---

### Code Snippet 2: Routes
```python
from flask import Flask, render_template, redirect, url_for
from flask_sqlalchemy import SQLAlchemy
from forms import RecipesForm

app = Flask(__name__)
app.config["SECRET_KEY"] = "secret"
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///recipes.db"
db = SQLAlchemy(app)


# Route to display all recipes
@app.route("/recipes", methods=["GET"])
def get_all_recipes():
    recipes = Recipe.query.all()
    return render_template("all_recipes.html", recipes=recipes)
```

---

### Code Snippet 3: Add recipe route
```python
@app.route("/create", methods=["POST", "GET"])
def create_recipe():
    form = RecipesForm()
    if form.validate_on_submit():
        recipe = Recipe(name=form.name.data, description=form.description.data, ingredients=form.ingredients.data, instructions=form.instructions.data)
        db.session.add(recipe)
        db.session.commit()
        return redirect(url_for("get_all_recipes"))
    return render_template("add_recipe.html", title="Add Recipe", form=form)
```

---

### Code Snippet 4: Edit recipe route
```python
@app.route("/edit/<int:recipe_id>", methods=["GET", "POST"])
def edit_recipe(recipe_id):
    recipe = Recipe.query.get_or_404(recipe_id)
    form = RecipesForm()
    if form.validate_on_submit():
        recipe.name = form.name.data
        recipe.description = form.description.data
        recipe.ingredients = form.ingredients.data
        recipe.instructions = form.instructions.data
        db.session.commit()
        return redirect(url_for("get_all_recipes"))
    elif request.method == "GET":
        form.name.data = recipe.name
        form.description.data = recipe.description
        form.ingredients.data = recipe.ingredients
        form.instructions.data = recipe.instructions
    return render_template("edit_recipe.html", title="Edit Recipe", form=form)
```

---

### Code Snippet 5: Templates
We have the template "all_recipes.html" to display all recipes and "add_recipe.html" and "edit_recipe.html" for adding and editing recipes respectively.

---

### Question:
What does the `create_recipe` function in Code Snippet 3 do?[/INST]