Skip to content

Commit fc1d316

Browse files
authored
Merge pull request #6 from Capstone-Projects-2022-Spring/FlaskApplication
Flask application
2 parents 73277f8 + 299c4ff commit fc1d316

33 files changed

Lines changed: 1144 additions & 0 deletions

.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/project-audibleon.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

__pycache__/config.cpython-310.pyc

704 Bytes
Binary file not shown.

config.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
3+
4+
5+
class Config(object):
6+
7+
# Secret Key Configuration (Either uses Environment Variable or a Hard Coded String)
8+
SECRET_KEY = os.environ.get('SECRET_KEY') or 'as;dlfkja;sdlkjf'
9+
10+
# Obtain Username, Password, and Database Name from Environment Variables
11+
#db_username = os.environ.get('DB_USER')
12+
#db_password = os.environ.get('DB_PASS')
13+
#db_name = os.environ.get('DB_NAME')
14+
db_username = os.environ.get('AWS_DB_USER')
15+
db_password = os.environ.get('AWS_DB_PASS')
16+
db_endpoint = os.environ.get('AWS_DB_ENDPOINT')
17+
db_name = os.environ.get('AWS_DB_NAME')
18+
19+
# SQLAlchemy Database Configuration
20+
#SQLALCHEMY_DATABASE_URI = f'mysql+pymysql://{db_username}:{db_password}@localhost:3307/{db_name}'
21+
SQLALCHEMY_DATABASE_URI = f'mysql+pymysql://{db_username}:{db_password}@{db_endpoint}:3306/{db_name}'
22+
SQLALCHEMY_ECHO = True
23+
SQLALCHEMY_TRACK_MODIFICATIONS = False

main.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from website import create_app
2+
3+
app = create_app()
4+
5+
app.app_context().push()
6+
7+
if __name__ == '__main__':
8+
app.run(debug=True)
9+
#run flask application

website/__init__.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from flask import Flask
2+
from config import Config
3+
from flask_sqlalchemy import SQLAlchemy
4+
5+
db = SQLAlchemy()
6+
7+
def create_app():
8+
9+
# Create the Object of Flask
10+
app = Flask(__name__)
11+
#app.config['SECRET_KEY'] = 'as;dlfkja;sdlkjf'
12+
13+
# Load the Configuration from the config.py file
14+
app.config.from_object(Config)
15+
16+
# Initialize the Application for the use with this Database Setup
17+
db.init_app(app)
18+
19+
with app.app_context():
20+
21+
# Import Views and Auth (Routes)
22+
from .views import views
23+
from .auth import auth
24+
25+
# Register the Blueprints used in Views and Auth
26+
app.register_blueprint(views, url_prefix='/')
27+
app.register_blueprint(auth, url_prefix='/')
28+
29+
# Create SQL Tables for our Data Models
30+
db.create_all()
31+
32+
return app

0 commit comments

Comments
 (0)