-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from AtomsForPeace/refactor_app
moved the creation of the app to the project init file. #14
- Loading branch information
Showing
2 changed files
with
33 additions
and
13 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
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import os | ||
|
||
from flask import Flask | ||
from flask_sqlalchemy import SQLAlchemy | ||
from flask_cors import CORS | ||
from flask_login import LoginManager | ||
|
||
|
||
db = SQLAlchemy() | ||
loginManager = LoginManager() | ||
|
||
|
||
def create_app(): | ||
app = Flask(__name__) | ||
app.secret_key = "ChocolateDBPassword" | ||
|
||
CORS(app, supports_credentials=True, resources={r"/*": {"origins": "*"}}) | ||
|
||
dirPath = os.getcwd() | ||
dirPath = os.path.dirname(__file__).replace("\\", "/") | ||
app.config["SQLALCHEMY_DATABASE_URI"] = f'sqlite:///{dirPath}/database.db' | ||
app.config['MAX_CONTENT_LENGTH'] = 4096 * 4096 | ||
app.config['UPLOAD_FOLDER'] = f"{dirPath}/static/img/" | ||
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False | ||
db.init_app(app) | ||
loginManager.init_app(app) | ||
loginManager.login_view = 'login' | ||
|
||
return app |