Can't reach Eve REST API
Asked Answered
R

1

7

I'm using Eve to create a REST API for MongoDB. It's all working fine, except for the fact that I can't reach the API from any other computer (in the same network), or even a different URL (e.g.: if I set SERVER_NAME = 'localhost:29000', I will not be able to reach the API with 127.0.0.1 and vice versa).

I've been looking around for hours, and I can't seem to find an answer. I also tried other REST API's for MongoDB like Kule, and they seem to work just fine, but they don't have as many options as Eve has.

Reserved answered 9/1, 2014 at 22:39 Comment(5)
Try binding the socket to 0.0.0.0 instead of 127.0.0.1 - the former means "all interfaces", the latter will bind it on localhost only.Papal
Sadly, it didn't work. The strange thing is though, that it always says: "Running on 127.0.0.1:29000", regardless of what IP address I fill in (the port does change).Reserved
Eve's SERVER_NAME seems to be based on the configuration variable by the same name from Flask: See "More on server name" below the table in the Flask Configuration docs. So it's really just for the name (hostname / subdomain handling) - the actual network interfaces it binds to therfore are probably determined by the server that runs the WSGI application. How are you serving your application?Papal
If you're just doing the app = Eve(); app.run() from the quickstart example, try app.run(host='0.0.0.0') and leave the server name empty (SERVER_NAME = '') - I've never used Eve, but from what I understand about how its built that should work.Papal
Wow, that worked! I really don't know how to thank you.Reserved
P
11

Eve's SERVER_NAME seems to be based on the configuration variable by the same name from Flask: See "More on server name" below the table in the Flask Configuration docs. So it's really just for the name (hostname / subdomain handling) - the actual network interfaces it binds to therfore are probably determined by the server that runs the WSGI application.

If you're just doing the

app = Eve()
app.run()

from the quickstart example, try

app.run(host='0.0.0.0')

instead and leave the server name empty (SERVER_NAME = '').

I've never used Eve, but from what I understand about how it's built that should work

Papal answered 9/1, 2014 at 23:21 Comment(3)
+1 for reminding me to add a host=0.0.0.0 note to the quickstart example. Had other people face the same kind of issue before.Jeroldjeroma
Other than that, docs are excellent from what I've been. Definitely will keep Eve in mind for the future :)Papal
I've been digging the web for several hours looking for issues related to flask. I didn't expect to be a flask-eve issue.You saved meUnrivaled

© 2022 - 2024 — McMap. All rights reserved.