Flask Routing fix
Co-authored-by: Shiva Pochampally <PieLord757@users.noreply.github.com>
This commit is contained in:
@@ -4,9 +4,28 @@ class MongoDB:
|
|||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.myclient = pymongo.MongoClient(config['MONGO_URI'])
|
self.myclient = pymongo.MongoClient(config['MONGO_URI'])
|
||||||
self.users = Users(self.myclient)
|
self.users = Users(self.myclient)
|
||||||
|
self.recipes = Recipes(self.myclient)
|
||||||
|
|
||||||
|
|
||||||
|
## User Schema
|
||||||
|
|
||||||
|
|
||||||
class Users:
|
class Users:
|
||||||
def __init__(self, db):
|
def __init__(self, db):
|
||||||
self.db = db
|
self.db = db
|
||||||
self.users = self.db.myclient['users']
|
self.users = self.db.myclient['users']
|
||||||
|
|
||||||
|
|
||||||
|
## Recipe Schema
|
||||||
|
class Recipe:
|
||||||
|
def __init__(self, name, ingredients, instructions, user):
|
||||||
|
self.name = name
|
||||||
|
self.ingredients = ingredients
|
||||||
|
self.instructions = instructions
|
||||||
|
self.rating = 0
|
||||||
|
self.user = user
|
||||||
|
|
||||||
|
class Recipes:
|
||||||
|
def __init__(self, db):
|
||||||
|
self.db = db
|
||||||
|
self.recipes = self.db.myclient['recipes']
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
class APIRoute:
|
|
||||||
def __init__(self, app, route, methods):
|
|
||||||
self.app = app
|
|
||||||
self.route = route
|
|
||||||
self.methods = methods
|
|
||||||
|
|
||||||
@self.app.route(self.route, methods=['GET'])
|
|
||||||
def get(self):
|
|
||||||
return "Hello World"
|
|
||||||
|
|
||||||
@self.app.route(self.route, methods=['POST'])
|
|
||||||
def post(self):
|
|
||||||
return "Hello World"
|
|
||||||
|
|
||||||
|
|
||||||
@@ -9,8 +9,8 @@ app = Flask(__name__)
|
|||||||
|
|
||||||
app.storage = MongoDB(config)
|
app.storage = MongoDB(config)
|
||||||
|
|
||||||
@app.route('/', methods=['GET'])
|
@app.route("/", methods=['GET'])
|
||||||
def hello_world():
|
def home():
|
||||||
return 'Hello, World!'
|
return "Hello World"
|
||||||
|
|
||||||
app.run(port=config['PORT'], debug=True)
|
app.run(port=config['PORT'])
|
||||||
Reference in New Issue
Block a user