Hi, I would like to apply a custom .grass file hosted on a local server to the local neo4j browser. I tried to add browser.post_connect_cmd=style 'http://localhost:9000/input/neo4j/style.grass'
to neo4j.conf
but when I load the browser it displays could not parse grass data
. Any help would be appreciated.
Hi @ch3n.wei.yi
That error message suggests that content is being found at the URL you provided to the command, which is good. When the content is hosted by a custom server a few things can go wrong.
- manually check the URL in a web browser
- if it looks like grass, try copying/pasting the grass directly into a
:style
command - is it served as a
plain/text
content type?
I just tried this using Parcel to host a local grass file and it works directly passed to :style
or using browser_post_connect_cmd
. What are you using to serve the file locally?
Best,
ABK
Thanks for the response. I've followed your suggestions and this is what I got:
- The URL is working, going to the URL leads to downloading the
grass
file but I'm not sure if that is the intended behaviour as I'm pretty new to this. For reference, I'm using Python'shttp.server
to serve the files on localhost. - I got the contents of the
grass
file directly from the neo4j browser using:style
but interestingly, when I copy the styling from the neo4j browser and paste it back to:style
, the style reverts back to the default style. - I'm serving it as a file on the server, not plain text.
Let me try your setup using http.server
from Python. Serving files can be subtly tricky if the content type and encoding aren't as expected.
BRB.
-ABK
TL;DR
- the
:style
command accepts inline grass content or a URL from which to load content - the single quotes around the URL makes it a string to be parsed instead of a URL from which to load content
- solution: remove the single quotes
Steps to reproduce error
I just tried serving the files using...
python3 -m http.server 9000
Using a web browser to go to the link directly downloads the .grass
file rather than showing the contents. In my case the URL is
http://localhost:9000/basic/movies.grass
Asking Neo4j Browser to load that style file works:
:style http://localhost:9000/basic/movies.grass
Looking back at your original post, I now notice you've placed the url within single quotes. That would make the :style
command try to parse the characters of the URL string itself as grass, which would fail with an easily misinterpreted error message like the following:
Thanks so much for your reply. That is exactly how I hosted my .grass
file.
I tested out the possibility of the quotation marks causing the error but that does not seem to be the case. I have tried:
- Single quotation marks (')
- Double quotation marks (")
- No quotation mark
Each time they returned the same error: InvalidGrassError Could not parse grass data.
Could you tell me which version of Neo4j and which version of Neo4j Browser you're using?
For Browser, clicking on the Neo4j logo in the bottom left corner will show a sidebar with the relevant versions.
For example, mine looks like:
Best,
ABK
Thanks for the tutorial on how to get the versions. Here is the version information I got: