Skip to content

Commit 0447048

Browse files
authored
Merge pull request #30 from clamsproject/quick-start
Quick start
2 parents 0b1ed87 + 754aed9 commit 0447048

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,23 @@ To get this code if you don't already have it:
3131
$ git clone https://github.com/clamsproject/mmif-visualizer
3232
```
3333

34+
## Quick start
3435

36+
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:
37+
38+
```
39+
./start_visualizer.sh <data_directory> <mount_directory>
40+
```
41+
42+
* The **required** `data_directory` argument should be the absolute or relative path of the media files on your machine which the MMIF files reference.
43+
* 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)
44+
45+
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:
46+
```
47+
./start_visualizer.sh /llc_data /data
48+
```
49+
50+
The server can then be accessed at `http://localhost:5000/upload`
3551

3652
## Running the server in a container
3753

app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def upload_file(in_mmif):
130130

131131
agent = request.headers.get('User-Agent')
132132
if 'curl' in agent.lower():
133-
return f"Visualization ID is {viz_id}\nYou can access the visualized file at /display/{viz_id}\n"
133+
return f"Visualization ID is {viz_id}\nYou can access the visualized file at {request.url_root}display/{viz_id}\n"
134134
return redirect(f"/display/{viz_id}", code=301)
135135

136136

start_visualizer.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Check for presence of Docker/Podman engines
2+
if command -v docker &> /dev/null
3+
then
4+
export container_engine=docker
5+
elif command -v podman &> /dev/null
6+
then
7+
export container_engine=podman
8+
else
9+
echo "Error: Docker or Podman not found. Please install container engine and try again."
10+
exit 1
11+
fi
12+
# Return if no inputs passed
13+
if [ -z "$1" ]
14+
then
15+
echo "Error: no data directory specified."
16+
exit 1
17+
fi
18+
# Set data directory to absolute path of input
19+
export datadir=$( cd $1; pwd )
20+
# Set mount directory to data directory if not specified
21+
if [ -z "$2" ]
22+
then
23+
echo "No mount directory specified: defaulting to $datadir"
24+
export mountdir=$datadir
25+
else
26+
export mountdir=$2
27+
fi
28+
# Start visualizer
29+
$container_engine build . -f Containerfile -t clams-mmif-visualizer
30+
$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
31+
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'"

0 commit comments

Comments
 (0)