-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
286 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
# import necessary modules | ||
import os | ||
from flask import Flask | ||
from dotenv import load_dotenv | ||
from pymongo import MongoClient | ||
|
||
# import blueprint for routes | ||
from movie_library.routes import pages | ||
|
||
# load environment variables from .env file | ||
load_dotenv() | ||
|
||
|
||
# function to create Flask application | ||
def create_app(): | ||
# create Flask app | ||
app = Flask(__name__) | ||
|
||
# set environment variables for the database URI and secret key | ||
app.config["MONGODB_URI"] = os.environ.get("MONGODB_URI") | ||
app.config["SECRET_KEY"] = os.environ.get( | ||
"SECRET_KEY", "pf9Wkove4IKEAXvy-cQkeDPhv9Cb3Ag-wyJILbq_dFw" | ||
) | ||
app.config["SECRET_KEY"] = os.environ.get("SECRET_KEY", "pf9Wkove4IKEAXvy-cQkeDPhv9Cb3Ag-wyJILbq_dFw") | ||
|
||
# connect to MongoDB database using the URI and get the default database | ||
app.db = MongoClient(app.config["MONGODB_URI"]).get_default_database() | ||
|
||
# register blueprint for routes | ||
app.register_blueprint(pages) | ||
|
||
# return the Flask app | ||
return app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.