@@ -0,0 +1,8 @@ | |||
# 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 |
@@ -1,3 +1,3 @@ | |||
web/app/__pycache__/ | |||
web/app/db.sqlite | |||
.env.dev | |||
.env.prod |
@@ -0,0 +1,21 @@ | |||
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' |
@@ -1,6 +1,7 @@ | |||
from flask import Flask | |||
from flask_sqlalchemy import SQLAlchemy | |||
from flask_login import LoginManager | |||
import os | |||
# init SQLAlchemy so we can use it later in our models | |||
db = SQLAlchemy() | |||
@@ -8,8 +9,8 @@ db = SQLAlchemy() | |||
def create_app(): | |||
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) | |||
@@ -4,14 +4,14 @@ from .models import Tool | |||
from werkzeug.exceptions import abort | |||
from . import db | |||
tool = Blueprint('tool', __name__) | |||
def get_tool(tool_id): | |||
tool = Tool.query.filter_by(id=tool_id).first() | |||
if tool is None: | |||
abort(404) | |||
return tool | |||
tool = Blueprint('tool', __name__) | |||
@tool.route('/tools') | |||
def get_tools(): | |||
tools = Tool.query |
@@ -1,4 +1,3 @@ | |||
flask | |||
requests | |||
flask-sqlalchemy | |||
flask-login |