Skip to content
forked from ispyb/py-ispyb

ISPyB backend server based on flask-restx

License

Notifications You must be signed in to change notification settings

clemenbor/py-ispyb

 
 

Repository files navigation

py-ispyb

codecov License: LGPL v3

ISPyB backend server based on python flask-restx.

Dependencies

How to run py-ispyb

Install requirements

In case of MySQL or MariaDB you might have to install dev tools:

sudo apt-get install -y python3-mysqldb

or

apt-get install libmariadbclient-dev

Install python dependencies:

sudo pip install -r requirements.txt

Copy and edit yaml configuration file

cp ispyb_core_config_example.yml ispyb_core_config.yml

If you do not have a running ispyb database then you can create one by running:

scripts/create_core_db.sh

Regenerate data base models and schemas

cd scripts
./generate_core_models.sh PATH_TO_CONFIG_FILE.yml
python3 generate_core_schemas.py
cd ..

Run application in debug mode

  • python3 wsgi.py
  • invoke app.run

Now you can go to http://localhost:5000/ispyb/api/v1/doc and explore py-ispyb via swagger ui. For authentication json web tokens (jwt) are used. In the web browser call http://localhost:5000/ispyb/api/v1/auth/login , enter user credentials and retrieve access token from the response:

{
    "token": "YOUR_JWT_TOKEN",
    "roles": [
        "user"
    ]
}

Corresponding curl command:

curl -u USER:PASS -i -H "Accept:application/json" http://localhost:5000/ispyb/api/v1/auth/login

In the case of dummy authentication username user will grant user role and manager will grant user and manager roles.

For requests use the token in the Authorization header: Bearer YOUR_JWT_TOKEN. For example to retrieve proposals call:

curl -X GET -H 'Authorization: Bearer YOUR_JWT_TOKEN' -i http://localhost:5000/ispyb/api/v1/proposals

Misc

About

ISPyB backend server based on flask-restx

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.9%
  • Other 1.1%