Skip to content

Commit

Permalink
Adapt to new dgp-auth version
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Dec 2, 2023
1 parent 8346732 commit 1c3635a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sqlalchemy
flask-cors
flask-jsonpify
flask-session
Flask-caching
PyYAML
python-slugify
psycopg2-binary
Expand Down
15 changes: 14 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from flask import Flask, redirect, send_file, Response, stream_with_context, request, abort
from flask_cors import CORS
from flask_session import Session
from flask_caching import Cache

os.environ['ALLOWED_SERVICES'] = 'etl-server:etl_server'

Expand Down Expand Up @@ -39,6 +40,18 @@
app.config['SECRET_KEY'] = '-'
session.init_app(app)

config = {
"CACHE_TYPE": "FileSystemCache", # Flask-Caching related configs
"CACHE_DEFAULT_TIMEOUT": 600,
"CACHE_DIR": "/tmp/cache",
"CACHE_THRESHOLD": 1000,
"CACHE_OPTIONS": {
"mode": 0o700
},
}
cache = Cache(config=config)
cache.init_app(app)


# Encode datetimes properly
class CustomJSONEncoder(json.JSONEncoder):
Expand Down Expand Up @@ -112,7 +125,7 @@ def options():
)
auth_connection_string = os.environ.get('AUTH_DATABASE_URL') or os.environ.get('DATABASE_URL')
app.register_blueprint(
auth_blueprint(os.environ.get('EXTERNAL_ADDRESS'), engine=get_engine(auth_connection_string)),
auth_blueprint(os.environ.get('EXTERNAL_ADDRESS'), engine=get_engine(auth_connection_string), cache=cache),
url_prefix='/auth/'
)

Expand Down

0 comments on commit 1c3635a

Please sign in to comment.