Skip to content

mm server

Bessie Malek edited this page Sep 7, 2017 · 3 revisions

The mm-server code is here: source code. This Node application is going to interface with the Raspberry Pi. It can take a picture and copy the pictures to cloud-node. It also serves the Magic_mirror Angular4 app.

Serve the Angular 4 app

The Angular4 app is build with angular-cli ng build. This creates some minified compressed files in the dist directory. These need to be copied to the server at the root of the mm-server in the dist directory. Then, server.js will serve the Angular app with this code:

//Serve Angular App to Browser upon GET / request
main.use(express.static(path.join(__dirname, 'dist')));

API calls

The important API calls, or endpoints are as follows:

  • POST '/picture'

This needs a body like this:

{
  directory: path, // required
  base_name: name, // name of picture
  options: {
    key: value
  }
}

This will take a picture and save it in the folder path.

  • DELETE '/picture/:folder'

where folder is the directory of pictures to delete. This will delete all the pictures in folder.

  • PUT '/picture/:folder'

This will copy all the pictures in folder to the cloud node.

Clone this wiki locally