vemonet / rdflib-endpoint

💫 Deploy SPARQL endpoints from RDFLib Graphs to serve RDF files, machine learning models, or any other logic implemented in Python
https://pypi.org/project/rdflib-endpoint
MIT License
72 stars 18 forks source link

Mounting on a Flask App #8

Open cthoyt opened 1 year ago

cthoyt commented 1 year ago

A web service I want to include a rdflib-endpoint instance in is built in Flask, can you add documentation on how to mount a rdflib_endpoint.SparqlEndpoint to an existing flask.Flask that doesn't require converting everything over to FastAPI?

vemonet commented 1 year ago

Hi @cthoyt do you have a pointer to this flask app please? To have a reference

I think this documentation is what you are searching for: https://fastapi.tiangolo.com/advanced/wsgi/

You can mount the whole flask app on the FastAPI app (in your case instantiated as SparqlEndpoint), then run everything on uvicorn

With this approach you still have your whole flask code as before, and the code to merge the flask API with the SPARQL endpoint is minimal and clear

If you prefer to really have flask at the root, it seems like flask is built on the same WSGI standard: https://flask.palletsprojects.com/en/2.2.x/deploying/gunicorn so you can probably mount the FastAPI/SparqlEndpoint app on the flask app (the same way as described in the FastAPI doc), and deploy the flask app with uvicorn/gunicorn

If you have a reference to the project I can check to see how it could be done exactly, and I'll add the process to the docs

cthoyt commented 1 year ago

Note that I would want to mount a fastapi app on a flask app, not the other way around