System for storing, indexing and visualizing medical data in DICOM format
- Install python3.12 interpreter
- Install dependencies with
pip install -r requirements.txt
- Create a database
YOUR_DB_NAME
for the project, specify the password for this database for your user. - Create
.env
file in root folder of project with following content:Note that DB_PORT indicates the server version of PostgreSQl, for more info on linux you can runDB_HOST = 'localhost' DB_PORT = '5438' DB_NAME = 'YOUR_DB_NAME' DB_USER = 'YOUR_USER' DB_PASSWORD = 'YOUR_PASSWORD'
pg_lsclusters
- Go to app folder, run
alembic init -t async migration
- Move
alembic.ini
file from app folder to root folder of project (mv alembic.ini ..
) - In file
alemvic.ini
change rowscript_location = migration
toscript_location = app/migration
- Open file app/migration/env.py, delete all contents from the beginning of the file up to and including line
target_metadata = None
(row 23) and insert the following content insteadPay attention toimport asyncio from logging.config import fileConfig from sqlalchemy import pool from sqlalchemy.engine import Connection from sqlalchemy.ext.asyncio import async_engine_from_config from alembic import context import sys from os.path import dirname, abspath sys.path.insert(0, dirname(dirname(abspath(__file__)))) from app.database import DATABASE_URL, Base from app.users.models import User # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config config.set_main_option("sqlalchemy.url", DATABASE_URL) # Interpret the config file for Python logging. # This line sets up loggers basically. if config.config_file_name is not None: fileConfig(config.config_file_name) target_metadata = Base.metadata # add your model's MetaData object here # for 'autogenerate' support # from myapp import mymodel # target_metadata = mymodel.Base.metadata
from app.users.models import User
, for each table in the database you need to add the corresponding import to this (env.py) file, however, at the moment there is a description only for the users table in app/users - Go to root folder of project, run
alembic revision --autogenerate -m "Initial revision"
, - Run
alembic upgrade head
, a users table has now been created in your database. To roll back changes runalembic downgrade -1
. For upgrade alternatively you can runalembic upgrade VERSION_ID
, where VERSION_ID is id from generated file from folder app/migration/versions which contains a line likeRevision ID: VERSION_ID
- Create
certs
directory and enter itmkdir certs && cd certs
- Create RSA256 private certificate
openssl genrsa -out jwt-private.pem 2048
- Create RSA256 public certificate based on private
openssl rsa -in jwt-private.pem -outform PEM -pubout -out jwt-public.pem
Run fastapi dev app/main.py
from root folder of project
To check tokens on the backend, log in with the appropriate token. Tokens can be obtained using the /user/login/
endpoint
/user/me
waiting for an access token to enter
/user/me/jwt/refresh_access_token
waiting for a refresh token to enter