Default port: 9000
Location | Description | Request JSON data | Response |
---|---|---|---|
/query |
Get card's seat number and name | uid : Card UIDkey : Preshared key |
num : Corresponding Seat numbername :Corresponding name |
/register |
Register a card to the database | uid : Card UIDnum : Seat numbername : Namekey : Preshared key |
200 (OK) if success |
/place |
Submit a temperature info to Google Sheets | num : Seat numbertemp : Body Temperaturekey : Preshared key |
202 (Accepted) if the request is accepted |
- Enable your Google Sheets API and download the
credentials.json
to the working directory - Generate SSL keys using
$ openssl genrsa -out server.key 2048
$ openssl req -new -x509 -key server.key -out server.crt -days 365
- Copy the example sheet to your account and edit it for your needs
- Rename
config.example.json
toconfig.json
and edit it:Key
: Pre-shared key. Requests to the server must contain the same keySheetsID
: ID of the spreadsheetTimeZone
: Specific time zone with IANA timezone database formatNoon
: Hours (1~24) after this value will be considered afternoon
- google.golang.org/api/sheets/v4
- golang.org/x/oauth2/google
- github.com/mattn/go-sqlite3
Use $ go mod download
to install them
$ go build
$ ./smart-therometer
# /etc/systemd/system/smart-thermometer.service
[Unit]
Description=Smart Thermometer
[Service]
WorkingDirectory=/home/yi/SmartThermometer-Server
ExecStart=/home/yi/SmartThermometer-Server/smart-thermometer
[Install]
WantedBy=multi-user.target
And then
$ sudo systemd enable --now smart-thermometer
to start and run on boot