dotenv MongoDB Update
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -130,3 +130,5 @@ dist
|
||||
.pnp.*
|
||||
|
||||
node_modules
|
||||
Backend/src/__pycache__
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import pymongo
|
||||
|
||||
class MongoDB:
|
||||
def __init__(self, config):
|
||||
self.myclient = pymongo.MongoClient(config['MONGO_URI'])
|
||||
self.users = Users(self.myclient)
|
||||
|
||||
|
||||
class Users:
|
||||
def __init__(self, db):
|
||||
self.db = db
|
||||
self.users = self.db.myclient['users']
|
||||
17
Backend/src/routes/Route.py
Normal file
17
Backend/src/routes/Route.py
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
|
||||
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"
|
||||
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
from flask import Flask
|
||||
from dotenv import dotenv_values
|
||||
|
||||
from db import MongoDB
|
||||
|
||||
config = dotenv_values(".env")
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
app.storage = MongoDB(config)
|
||||
|
||||
@app.route('/', methods=['GET'])
|
||||
def hello_world():
|
||||
return 'Hello, World!'
|
||||
|
||||
app.run(port=5000)
|
||||
app.run(port=config['PORT'], debug=True)
|
||||
Reference in New Issue
Block a user