diff --git a/README.md b/README.md index c8984e9..07f5fb9 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,23 @@ To get this code if you don't already have it: $ git clone https://github.com/clamsproject/mmif-visualizer ``` +## Quick start +If you just want to get the server up and running quickly, the repository contains a shell script `start_visualizer.sh` to immediately launch the visualizer in a container. You can invoke it with the following command: + +``` +./start_visualizer.sh +``` + +* The **required** `data_directory` argument should be the absolute or relative path of the media files on your machine which the MMIF files reference. +* The **optional** `mount_directory` argument should be specified if your MMIF files point to a different directory than where your media files are stored on the host machine. For example, if your video, audio, and text data is stored locally at `/home/archive` but your MMIF files refer to `/data/...`, you should set this variable to `/data`. (If this variable is not set, the mount directory will default to the data directory) + +For example, if your media files are stored at `/llc_data` and your MMIF files specify the document location as `"location": "file:///data/...`, you can start the visualizer with the following command: +``` +./start_visualizer.sh /llc_data /data +``` + +The server can then be accessed at `http://localhost:5000/upload` ## Running the server in a container diff --git a/app.py b/app.py index 5e53c65..7294b59 100644 --- a/app.py +++ b/app.py @@ -130,7 +130,7 @@ def upload_file(in_mmif): agent = request.headers.get('User-Agent') if 'curl' in agent.lower(): - return f"Visualization ID is {viz_id}\nYou can access the visualized file at /display/{viz_id}\n" + return f"Visualization ID is {viz_id}\nYou can access the visualized file at {request.url_root}display/{viz_id}\n" return redirect(f"/display/{viz_id}", code=301) diff --git a/start_visualizer.sh b/start_visualizer.sh new file mode 100755 index 0000000..a23ccc4 --- /dev/null +++ b/start_visualizer.sh @@ -0,0 +1,31 @@ +# Check for presence of Docker/Podman engines +if command -v docker &> /dev/null +then + export container_engine=docker +elif command -v podman &> /dev/null +then + export container_engine=podman +else + echo "Error: Docker or Podman not found. Please install container engine and try again." + exit 1 +fi +# Return if no inputs passed +if [ -z "$1" ] +then + echo "Error: no data directory specified." + exit 1 +fi +# Set data directory to absolute path of input +export datadir=$( cd $1; pwd ) +# Set mount directory to data directory if not specified +if [ -z "$2" ] +then + echo "No mount directory specified: defaulting to $datadir" + export mountdir=$datadir +else + export mountdir=$2 +fi +# Start visualizer +$container_engine build . -f Containerfile -t clams-mmif-visualizer +$container_engine run -d --name clams-mmif-visualizer --rm -p 5000:5000 -e PYTHONUNBUFFERED=1 -v $datadir:$mountdir -v $datadir:/app/static/$mountdir clams-mmif-visualizer +echo "MMIF Visualizer is running in the background and can be accessed at http://localhost:5000/. To shut it down, run '$container_engine kill clams-mmif-visualizer'" \ No newline at end of file