| # This config file contains the environment variables for the application and for the database | |||||
| # Flask variables | |||||
| FLASK_APP=app | |||||
| FLASK_RUN_HOST=0.0.0.0 | |||||
| FLASK_ENV=development | |||||
| SECRET_KEY=f9DWPyF70N | |||||
| DATABASE_URL=sqlite:///db.sqlite |
| web/app/__pycache__/ | web/app/__pycache__/ | ||||
| web/app/db.sqlite | web/app/db.sqlite | ||||
| .env.dev | |||||
| .env.prod |
| version: "3.9" | |||||
| services: | |||||
| web: | |||||
| build: ./web | |||||
| container_name: python | |||||
| ports: | |||||
| - "5000:5000" | |||||
| volumes: | |||||
| - ./web:/code | |||||
| env_file: | |||||
| - ./.env.prod | |||||
| db: | |||||
| image: mariadb:latest | |||||
| container_name: mariadb | |||||
| restart: unless-stopped | |||||
| env_file: | |||||
| - ./.env.prod | |||||
| volumes: | |||||
| dbdata:/var/lib/mysql | |||||
| command: '--default-authentication-plugin=mysql_native_password' |
| from flask import Flask | from flask import Flask | ||||
| from flask_sqlalchemy import SQLAlchemy | from flask_sqlalchemy import SQLAlchemy | ||||
| from flask_login import LoginManager | from flask_login import LoginManager | ||||
| import os | |||||
| # init SQLAlchemy so we can use it later in our models | # init SQLAlchemy so we can use it later in our models | ||||
| db = SQLAlchemy() | db = SQLAlchemy() | ||||
| def create_app(): | def create_app(): | ||||
| app = Flask(__name__) | app = Flask(__name__) | ||||
| app.config['SECRET_KEY'] = 'f9DWPyF70N' | |||||
| app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite' | |||||
| app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY') | |||||
| app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL') | |||||
| db.init_app(app) | db.init_app(app) | ||||
| from werkzeug.exceptions import abort | from werkzeug.exceptions import abort | ||||
| from . import db | from . import db | ||||
| tool = Blueprint('tool', __name__) | |||||
| def get_tool(tool_id): | def get_tool(tool_id): | ||||
| tool = Tool.query.filter_by(id=tool_id).first() | tool = Tool.query.filter_by(id=tool_id).first() | ||||
| if tool is None: | if tool is None: | ||||
| abort(404) | abort(404) | ||||
| return tool | return tool | ||||
| tool = Blueprint('tool', __name__) | |||||
| @tool.route('/tools') | @tool.route('/tools') | ||||
| def get_tools(): | def get_tools(): | ||||
| tools = Tool.query | tools = Tool.query |
| flask | flask | ||||
| requests | |||||
| flask-sqlalchemy | flask-sqlalchemy | ||||
| flask-login | flask-login |