AI_chatbhot / app.py
geethareddy's picture
Update app.py
ca84be9 verified
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()