"Unexpected character encountered" when trying to connect hops to python

Hi, I’m very new to coding, Python and APIs.
I’m trying to run the simple example of connecting app.py (with a pointat function) to grasshopper Hops. I installed Python 3.9 and the needed libraries, this is the code:

from flask import Flask
import ghhops_server as hs

import rhino3dm

# Register Hops app as middleware
app = Flask(__name__)
hops = hs.Hops(app)


@hops.component(
    "/pointAt",
    name="PointAt",
    description="Get point along curve",
    # icon="pointat.png"
    inputs=[
        hs.HopsCurve("Curve", "C", "Curve to evaluate"),
        hs.HopsNumber("t", "t", "Parameter on Curve to evaluate", default=0.5),
    ],
    outputs=[
        hs.HopsPoint("P", "P", "Point on curve at t"),
    ]
)
def pointat(curve: rhino3dm.Curve, t):
    return curve.PointAt(t)


if __name__ == "__main__":
    app.run()

After running

python .\app.py

I’m giving the Hops component the server address: http://127.0.0.1:5000/pointat, and what I’m getting is this Error:

1. Unexpected character encountered while parsing value: <. Path '', line 0, position 0.

In the PyCharm terminal what I’m seeing is:

[INFO] 127.0.0.1 - - [06/Jan/2023 17:16:28] "GET /pointat HTTP/1.1" 404 -
[INFO] 127.0.0.1 - - [06/Jan/2023 17:16:40] "GET /pointat HTTP/1.1" 404 -

I feel like I’ve been through everything I saw on the internet, I just can’t seem to get it to work.

Thanks in advance

Hey,

try changing the endpoint to /pointat in the component definition (all lowercase)
it also looks that your component is missing "outputs" = [...

1 Like

Can’t believe this entire thing was one capitalized letter… Thanks a lot! Now it works

1 Like