camelot-dev / excalibur

A web interface to extract tabular data from PDFs
https://excalibur-py.readthedocs.io
MIT License
1.56k stars 227 forks source link

Feature Request: subfolder path for deployment #148

Open answerquest opened 2 years ago

answerquest commented 2 years ago

Feature request: Pls add a control in the .cfg for a subfolder under which the server can be deployed.

Presently it by default tries to deploy itself at top-level root. That's not feasible for situations like deployment on a server, as there might be other things occupying the top level there.

answerquest commented 2 years ago

I was able to get the webpages to come under a subfolder by editing excalibur/www/views.py . Exporting the path in an env param before launching:

export EXCALIBUR_SUBPATH=/excalibur1
excalibur webserver

excalibur/www/views.py:


subpath = os.environ.get('EXCALIBUR_SUBPATH','')

@views.route(subpath+"/", methods=["GET"])
...
@views.route(subpath+"/files", methods=["GET", "POST"])

and so on. But getting stuck with the js/css libs importing. It keeps trying for /static/js/files.js etc and I'm not able to make it come under /excalibur1/.
Replacing in the url template .html files didn't help:

<script type="text/javascript" src="{{ url_for('static', filename='js/files.js') }}"></script>

If I change this to

<script type="text/javascript" src="{{ url_for('static', filename='js/files.js') }}"></script>

Then this throws a python error.

If anybody knows a way around this then pls share. I've made a fork here: https://github.com/answerquest/excalibur