Esempio n. 1
0
def main():
    try:
        port = int(sys.argv[1])
    except:
        print("Usage: %s <port>" % sys.argv[0])
        return

    resource_dir = os.path.join(root_dir, 'resources')
    Recipe.set_resource_dir(resource_dir)

    Recipe.load_recipe()
    register(Recipe.save_recipe)

    app.add_url_rule('/', view_func=Recipe.as_view('recipe'))
    app.run(host='0.0.0.0', port=port, debug=True)
Esempio n. 2
0
"""
A simple Desserts flask app.
"""
import flask
import os
from flask.views import MethodView
from index import Index
from suggest import Suggest
from view import View
from recipe import Recipe

app = flask.Flask(__name__)  # our Flask app

#index uses GET method
app.add_url_rule('/', view_func=Index.as_view('index'), methods=['GET'])
#sign uses GET and POST methods
app.add_url_rule('/suggest/',
                 view_func=Suggest.as_view('suggest'),
                 methods=['GET', 'POST'])
#view file uses GET method to fetch and display the list
app.add_url_rule('/view/', view_func=View.as_view('view'), methods=['GET'])
#recipe uses both get and post
app.add_url_rule('/recipe/',
                 view_func=Recipe.as_view('recipe'),
                 methods=['GET', 'POST'])
#Deployed at port 5000
if __name__ == '__main__':
    app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 5000)))