This repository contains the definitions for a Flask app (subdirectory app
) and React client (subdirectory client
) which are used as web-frontend for the Digital Curation Manager
.
The Flask app
- provides means to handle authorization,
- acts as a gateway to a
DCM Backend
-app, and - serves the static web-client.
The contents of this repository are part of the Digital Curation Manager
.
Make sure to include the extra-index-url https://zivgitlab.uni-muenster.de/api/v4/projects/9020/packages/pypi/simple
in your pip-configuration to enable an automated install of all dependencies.
Using a virtual environment is recommended.
- Change into the
app
-directory. - Install with
(See this section if you prefer to build the app yourself.)
pip install dcm-frontend
- Configure service environment to fit your needs (see here).
- Run app as
flask run --port=8080
- Open the client in your webbrowser at
http://localhost:8080
.
During development, the Flask app and React client can be run separately. This automatically enables the npm-auto-refresh for changes in the client-code.
- To start the Flask-App first change to the
app
-directory and configure the environment to fit your needs (see here). - Install the package as
pip install -r dev-requirements.txt pip install .
- Run app as
ALLOW_CORS=1 flask run
- Use an example command for an endpoint with command line tools like
curl
as, e.g.,where the password is md5-hashed manually beforehand.curl -X 'POST' \ 'http://localhost:5000/api/auth/login' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "userId": "Einstein", "password": "8acc99eb2fceac8e027fbc1e6d60a98d" }'
- To start the Client server, first change to the
client
-directory and configure the environment to fit your needs (see here). - To install the necessary dependencies run
npm install
. - Run client as
npm start
- By default the server will listen on
localhost:3000
.
In a production environment, the static client is intended to be served via the Flask app. To perform a build of the corresponding python package, follow these steps:
- Change into the client directory with
cd client
. - Install dependencies with
npm install
. - Run a build of client with
npm run build
. - Move the generated static website from the
client/build
- into theapp/dcm_frontend/client
-directory viarm -r ../app/dcm_frontend/client mv build ../app/dcm_frontend/client
- After changing into the
app
-directory, build a python package by, for example, enteringpython3 generate_build_info.py # generates a module with build-metadata (optional) python3 setup.py sdist bdist_wheel
After the generated package is installed, use the dcm_frontend.app_factory
to create a flask-app (see app/app.py
for an example).
The two components of this repository support the following options for configuration via environment
SECRET_KEY
[DEFAULT "020601e2d51d69e07fdbf29fd5bfa790"] secret (general-purpose) encryption keyALLOW_CORS
[DEFAULT 0] enable CORS for developmentDEV_CLIENT_URL
[DEFAULT "http://localhost:3000"] client url for CORS-requests during developmentSTATIC_PATH
[DEFAULT "client"] static web-client directoryLOGO_PATH
[DEFAULT null] path to logo fileWELCOME_MESSAGE_TEMPLATE
[DEFAULT "..."] python format string used on the home-page after login; format kwargs areVERSION
for package version andBUILD_DATETIME
for the datetime during packagingBACKEND_HOST
[DEFAULT http://localhost:8086] host address for Backend-serviceBACKEND_TIMEOUT
[DEFAULT 10] timeout duration for requests to the Backend-service in secondsOAI_TIMEOUT
[DEFAULT 60]: timeout for single connections to oai-repositories in secondsOAI_MAX_RESUMPTION_TOKENS
[DEFAULT 5]: maximum number of processed resumption tokens during a connection to oai-repositories
There are some advanced options for configuration available via the AppConfig
-class that is passed to the app-factory. The default configuration is located in the module app/dcm_frontend/config.py
.
REACT_APP_API_URL
[DEFAULT ""] base url for backend; when running thenpm start
-script, the variable is automatically set tohttp://localhost:5000
- Sven Haubold
- Orestis Kazasidis
- Stephan Lenartz
- Kayhan Ogan
- Michael Rahier
- Steffen Richters-Finger
- Malte Windrath
- Roman Kudinov