Skip to content

North101/pico-frame-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PicoFrame Server

This is a server for my PicoFrame.

It uses a Google Cloud Service Account to find images uploaded to google drive and then crop and resize them for a Pimoroni InkyFrame.

Installing

Requirements: Node.js

Building

yarn run build

Running

Development with hot reload

yarn run dev

Production (after building)

node dist/server/main.js

Config

# Port the server listens to
PORT=4000

# API Key protecting the endpoints
API_KEY=

# Path to Google Cloud Service Account credentials
# (see below)
CREDENTIALS=./credentials.json

# Google Drive folder ids to look in.
# If this is empty then the server will download
# anything shared with the google service account
FOLDER_IDS=

# Path to save images to
IMAGE_DIR=./pico_frame_images/

# Supported image mime types
IMAGE_MIME_TYPES=image/jpeg,image/png,image/gif,image/bmp

# Image height
IMAGE_HEIGHT=480

# Image width
IMAGE_WIDTH=800

# cron schedule for syncing drive files.
# See https://crontab.guru/#*/5_*_*_*_*
SYNC_DRIVE_SCHEDULE="*/5 * * * *"

# Whether to sync drive on start up
SYNC_DRIVE_IMMEDIATELY=false

Google Cloud Service Account

To list and download images from your google drive you will need a google cloud service account.

Head over to https://console.cloud.google.com/apis/credentials. If you've not already signed up, you will need to agree to the terms and services.

Create a new project and give it a name.

Enable Google Drive APIs
  1. Click on Enabled APIs & Services then + Enable APIs and Services

  2. Search for Drive and click on Google Drive API and then Enable

Setup OAuth details
  1. Click on OAuth consent screen and select External then create

  2. Fill in the required details and anything else you want and click Save and continue.

  3. Click Add or remove scopes

  4. Search for /auth/drive.readonly and check it

  5. Click Update at the bottom.

  6. Click Save and continue

  7. Add any test users you'd like and then click Save and continue

Create service account
  1. Click Credentials

  2. Click + Create Credentials then Service account

  3. Fill in the name

  4. Click Save and continue

  5. Click Continue

  6. Click Done

Create service account keys
  1. Click on the service account you just created

  2. Click the Keys tab

  3. Click Add Key then Create new key

  4. Select JSON then Create

  5. Save the key and place it in the project folder named credentials.json

Give your service account access to your google drive
  1. Click on your service account then Details

  2. Copy the email address

  3. Go to https://drive.google.com/drive/ and click on a file or folder your want to make available to your service account

  4. Click Share and paste the email address into the text box and click Send

  5. Repeat for each file and folder your want to share

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published