diff --git a/api/.gitignore b/quotes-api/.gitignore similarity index 100% rename from api/.gitignore rename to quotes-api/.gitignore diff --git a/api/Dockerfile b/quotes-api/Dockerfile similarity index 100% rename from api/Dockerfile rename to quotes-api/Dockerfile diff --git a/api/README.md b/quotes-api/README.md similarity index 100% rename from api/README.md rename to quotes-api/README.md diff --git a/api/app.py b/quotes-api/app.py similarity index 92% rename from api/app.py rename to quotes-api/app.py index afe4465..1ed3190 100644 --- a/api/app.py +++ b/quotes-api/app.py @@ -1,3 +1,4 @@ +import logging import os import flask @@ -7,17 +8,25 @@ import flask_restful.fields import flask_restful.reqparse import itsdangerous import sqlalchemy +import sqlalchemy.engine from db import db, Quote app = flask.Flask(__name__) +app.logger.setLevel(logging.INFO) app.config.update( ERROR_404_HELP=False, SQLALCHEMY_TRACK_MODIFICATIONS=False, SQLALCHEMY_DATABASE_URI=os.getenv('SQLALCHEMY_DATABASE_URI'), SECRET_KEY=os.getenv('SECRET_KEY')) +if app.config.get('SQLALCHEMY_DATABASE_URI', '').startswith('sqlite://'): + @sqlalchemy.event.listens_for(sqlalchemy.engine.Engine, 'connect') + def set_sqlite_pragma(dbapi_connection, connection_record): + dbapi_connection.execute('PRAGMA journal_mode=WAL') + dbapi_connection.execute('PRAGMA synchronous=NORMAL') + db.init_app(app) db.create_all(app=app) diff --git a/api/db.py b/quotes-api/db.py similarity index 100% rename from api/db.py rename to quotes-api/db.py diff --git a/api/generate_api_key.py b/quotes-api/generate_api_key.py similarity index 100% rename from api/generate_api_key.py rename to quotes-api/generate_api_key.py diff --git a/api/requirements.txt b/quotes-api/requirements.txt similarity index 100% rename from api/requirements.txt rename to quotes-api/requirements.txt