geethareddy commited on
Commit
ca84be9
·
verified ·
1 Parent(s): 1d3c09f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -1
app.py CHANGED
@@ -35,4 +35,27 @@ def get_recipes():
35
  return render_template('index.html', recipes=suggested_recipes)
36
 
37
  if __name__ == '__main__':
38
- app.run(debug=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  return render_template('index.html', recipes=suggested_recipes)
36
 
37
  if __name__ == '__main__':
38
+ # Using Gunicorn server in production
39
+ from gunicorn.app.base import BaseApplication
40
+ from gunicorn.six import iteritems
41
+
42
+ class StandaloneApplication(BaseApplication):
43
+ def __init__(self, app, options=None):
44
+ self.options = options or {}
45
+ self.app = app
46
+ super().__init__()
47
+
48
+ def load(self):
49
+ return self.app
50
+
51
+ def load_config(self):
52
+ config = {key: value for key, value in iteritems(self.options)}
53
+ for key, value in iteritems(config):
54
+ self.cfg.set(key.lower(), value)
55
+
56
+ options = {
57
+ 'bind': '0.0.0.0:5000', # Bind to all interfaces on port 5000
58
+ 'workers': 2, # Number of worker processes
59
+ }
60
+
61
+ StandaloneApplication(app, options).run()