File size: 1,900 Bytes
882d9e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ca84be9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from flask import Flask, request, render_template
app = Flask(__name__)

# Recipe suggestions based on ingredients
recipes = {
    "paneer": [
        "Paneer Butter Masala", "Palak Paneer", "Paneer Tikka", "Paneer Bhurji", "Shahi Paneer"
    ],
    "lettuce": [
        "Lettuce Salad", "Lettuce Wraps", "Lettuce and Avocado Salad", "Caesar Salad"
    ],
    "carrot": [
        "Carrot Halwa", "Carrot Soup", "Carrot Salad", "Carrot Cake", "Pickled Carrots"
    ],
    "broccoli": [
        "Broccoli Stir Fry", "Broccoli Soup", "Broccoli Salad", "Steamed Broccoli"
    ],
    "mushrooms": [
        "Mushroom Masala", "Mushroom Soup", "Mushroom Risotto", "Stuffed Mushrooms"
    ]
}

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/get_recipes', methods=['POST'])
def get_recipes():
    selected_ingredients = request.form.getlist('ingredients')
    suggested_recipes = []

    for ingredient in selected_ingredients:
        suggested_recipes.extend(recipes.get(ingredient, []))
    
    return render_template('index.html', recipes=suggested_recipes)

if __name__ == '__main__':
    # Using Gunicorn server in production
    from gunicorn.app.base import BaseApplication
    from gunicorn.six import iteritems

    class StandaloneApplication(BaseApplication):
        def __init__(self, app, options=None):
            self.options = options or {}
            self.app = app
            super().__init__()

        def load(self):
            return self.app

        def load_config(self):
            config = {key: value for key, value in iteritems(self.options)}
            for key, value in iteritems(config):
                self.cfg.set(key.lower(), value)

    options = {
        'bind': '0.0.0.0:5000',  # Bind to all interfaces on port 5000
        'workers': 2,  # Number of worker processes
    }

    StandaloneApplication(app, options).run()