Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: Samples or Demos? #262

Open
jlpoolen opened this issue Mar 11, 2023 · 4 comments
Open

API: Samples or Demos? #262

jlpoolen opened this issue Mar 11, 2023 · 4 comments

Comments

@jlpoolen
Copy link
Contributor

I'm trying to utilize the API and running into cross-domain issues if I create an HTML file with a JavaScript file on my laptop trying to send an xmlhttp request to my moonfire-nvr instance (server identified by IP) running on a raspberry pi server. I've used APIs in the past when I have had to, but here I'm getting tripped up by things like

 CORS header 'Access-Control-Allow-Origin' missing  

While I'm slogging through trying to get over the CORS issues, I finally decided to install an instance of moonfire-nvr on my laptop so the moonfire instance is on the same "localhost" machine and hopefully doesn't trigger all the glorious protection devices built into Firefox to save me from malicious machinations. All this is leading to a request here in this Issue of possibly sharing some demonstration files of HTML and JavaScript which illustrate the API. I was thinking of trying to have a sample set for each API call so someone doesn't really have to think or be fully aware of all the security ramifications when testing the API.

Lastly, I'm an Apache fan and the fact the moonfire-nvr runs on something other than Apache, nginx?, just adds another technology I have to become slightly familiar with in order to just deploy a test HTML file. So, any pointers such as "place your test html files here" within the server's directory structure would go a long way. I'm also a Perl fan and suppose cgi-bin in frowned upon, but if it is a simple matter to stage Perl scripts under the moonfire server as I would on Apache under cgi-bin, knowing how to do so would really be helpful. I feel like I'm speaking one language in a foreign jurisdiction and making requests to have someone in my native tongue.

@jlpoolen
Copy link
Contributor Author

I'll add why now I'm focused on the API. I've got the Google Coral libraries supporting the USB unit to work in Gentoo LInux. Now I'm focusing on gstreamer (which I recommend you build outside of Gentoo's portage system which, in my opinion, just complicates and breaks up gstreamer into countless units -- much like Gentoo's implementation of thousands of Perl packages) and the next step is to try and harness mining videos directly from moonfire-nvr for edge detection [classifying objects such as people, cars, bicyclists]. So I thought I would try the API to see if I can identify videos and then pull them out for analysis.

@jlpoolen
Copy link
Contributor Author

I'm making progress, albeit using the command "curl". I do not know if I should document here, or perhaps start a wiki page on using curl for the API.

@jlpoolen
Copy link
Contributor Author

Below needs to be run on the same box as the moonfire-nvr instance.

# below works, have the cookie returned by the server stored locally by curl using "--cookie-jar" parameter
curl -i -X POST --json '{"username": "jlpoole", "password":"XXXXXXXX"}' --cookie-jar cookies.txt localhost:8080/api/login

# below works, note the final forward slash "/" after "api", ommission of this character is fatal
curl -i -X GET --cookie cookies.txt http://localhost:8080/api/

@jlpoolen
Copy link
Contributor Author

I think I have some Perl scripts that let you pull specific videos, If they are of interest and useful, what is the best way to share them?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant