Run gramps-web server without Docker?

@DavidMStraub, what would it take to make gramps-web be usable as my local desktop gramps?

For example, I’d like to just start up the flask server, and go to localhost:port and start using gramps-web. This would be similar to how Jupyter Lab and other client/server systems work. This would also be useful for development.

Questions:

  1. Is this possible without using Docker? I don’t mind logging in if necessary.
  2. If so, can I use my sqlite database?
  3. Would there be any issues? I know Jupyter went for years with a security token, but with that, it should also be secure, right?

Is this possible without using Docker? I don’t mind logging in if necessary.

Yes, that’s definitely possible. gramps_webapi is a pip-installable Python package and a flask app, so you can run the flask development server (warning: do not use to deploy a website) to run it. The package also has its own CLI script for convenience, see python -m gramps_webapi --help.

I personally don’t use docker during development and the command I use is:

LANGUAGE=en python3 -O -m gramps_webapi --config some_config.cfg run --port 5555

If so, can I use my sqlite database?

Yes, it will use your normal grampsdb by default. You can use TREE='My Tree Name' to select the tree to use.

Would there be any issues?
To use all the features (e.g. import and export), it makes sense to run celery as well. This also works without docker:

GRAMPS_API_CONFIG=some_config.cfg celery -A gramps_webapi.celery worker --loglevel=INFO

but you also need Redis, which I have never tried outside of docker since it’s so simple to spin up a redis container.

I know Jupyter went for years with a security token, but with that, it should also be secure, right?

I’m not sure what you mean by secure - clearly, such a setup is only good for local testing, without HTTPS it’s completely insecure and the flask development server is not suited for production.

1 Like

What is redis needed for?

I don’t think security is an issue if you are just running it locally, correct? When you say “not suited for production” you mean when not run locally, correct?

As message broker for celery. Gramps Web (API) will mostly work also without celery, but some long-running operations might time out. But for some of them (e.g. creating a search index), you can also directly use the command line, which doesn’t suffer from the timeout problem.

Right.

1 Like

Thanks for the info! I’m going to try to make gramps-web my desktop gramps :smile:

2 Likes

Starts up, but browser page is empty. Any ideas?

$ FLASK_DEBUG=1 LANGUAGE=en python -m gramps_webapi --config gramps-web.cfg run --port 5555
 * Serving Flask app 'gramps_webapi.app'
 * Debug mode: on
INFO:werkzeug:WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:5555
INFO:werkzeug:Press CTRL+C to quit
INFO:werkzeug: * Restarting with watchdog (inotify)
WARNING:werkzeug: * Debugger is active!
INFO:werkzeug: * Debugger PIN: 598-699-581
INFO:werkzeug:127.0.0.1 - - [13/Nov/2024 12:12:17] "GET / HTTP/1.1" 304 -
INFO:werkzeug:127.0.0.1 - - [13/Nov/2024 12:12:17] "GET /favicon.ico HTTP/1.1" 304 -
INFO:werkzeug:127.0.0.1 - - [13/Nov/2024 12:12:30] "GET /favicon.ico HTTP/1.1" 304 -

@DavidMStraub any hints as to how I can begin to debug this?

Hi @dsblank, do you want to run Gramps Web API only or the whole web app?

If you’re only running the API, it’s expected to get a blank page. You can interact with it by sending HTTP requests (manually with curl, using httpie as described here or perhaps using my half-finished API client). API docs are here.

If you want to run the web app, you also need to download the frontend (e.g. the released one here if you don’t want to build form source) and set the STATIC_PATH config option accordingly.

Thanks! That was enough to get me going, but there are a lot of missing pieces in the docs. I found this page by searching, but it doesn’t appear in the menu that I could find.

Here are my step-by-step instructions if one wants to run gramps-web locally.

  1. Make sure you have gramps, gramps-web-api, and gramps-web installed. I git cloned each of them and pip install -e . each to have a development environment
  2. Create a gramps-web.config file, like the following:
TREE="Example"
BASE_URL="http://127.0.0.1/"
SECRET_KEY="my-secret-key"
USER_DB_URI="sqlite:////home/dsblank/.gramps/grampsdb/658d7f18/sqlite.db"
  1. Next, build the frontend
cd gramps-web
npm run build

That may show some errors, but as long as it says created dist in XXXs then you should be good. That creates the frontend files in the dist folder.

  1. Let gramps-web know where to find the frontend, like this:
export GRAMPSWEB_STATIC_PATH=/home/dsblank/gramps/gramps-web/dist
  1. Create an account (replacing all-caps parts and your fullname):
gramps_webapi --config gramps-web.cfg user add --fullname "Doug Blank" --role 5 USERNAME PASSWORD
  1. Run, with some additional debugging:
FLASK_DEBUG=1 LANGUAGE=en gramps_webapi --config gramps-web.cfg run --port 5555

There may be a few more settings (and I’ll report) but this will get the system started.

@DavidMStraub are you open to PRs? I already see some low-hanging fruit to make the process better.

3 Likes

Correct, alternatively, one can use the built frontend from the release page like the one I linked above.

@DavidMStraub are you open to PRs?

:exploding_head: YES

The docs are lacking, as you rightly point out, the repo is here GitHub - gramps-project/gramps-web-docs: Documentation for Gramps Web

For the frontend/backend repos, I find it always easiest to start with opening an issue.

I also realize we don’t have a CONTRIUBUTING.md in either of the repos, we really should.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.