Giter Club home page Giter Club logo

pi-admin-app's Introduction

Pi Admin App

A simple web application built using Go that allows you to manage some functionalities of your Raspberry Pi without the need of a terminal. The application serves an HTML page with buttons to perform various actions, such as rebooting the Raspberry Pi.

Features

  • Web-based interface
  • Reboot Raspberry Pi with a button click
  • Easy to extend with more buttons and functionalities
  • Serves static files for JavaScript and other assets
  • Can be run as a daemon service on Raspberry Pi

Project Structure

This Go application is organized to keep HTML templates, JavaScript functions, and server-side handlers separate. You can easily add more buttons and functionalities by following these steps:

  1. Add a new button with an onclick event handler in the HTML template in the serveHTML function.
  2. Define a new JavaScript function for the button's onclick event in the main.js file.
  3. Create a new server-side handler function in the main.go file, if required.
  4. Register the new handler function with a URL path in the main() function.

Running the App as a Daemon Service

To make the Go app run automatically when the Raspberry Pi restarts, you can create a systemd service. Here are the steps:

  1. Build your Go application, if you haven't done so already:
go build main.go
  1. Move the compiled binary to a suitable location, like /usr/local/bin:
sudo mv main /usr/local/bin/pi-admin-app
  1. Create a systemd service file for your application by creating a new file /etc/systemd/system/pi-admin-app.service:
sudo nano /etc/systemd/system/pi-admin-app.service
  1. Add the following contents to the service file:
[Unit]
Description=Raspberry Pi Control Panel Web Server
After=network.target

[Service]
User=root
Group=root
ExecStart=/usr/local/bin/pi-admin-app
Restart=on-failure

[Install]
WantedBy=multi-user.target

This configuration specifies that the service should start after the network target is reached, run as root, and restart if the process fails. Adjust the User and Group fields if you want to run the service under a different user.

  1. Reload the systemd configuration:
sudo systemctl daemon-reload
  1. Enable the service to start on boot:
sudo systemctl enable pi-admin-app.service
  1. Start the service:
sudo systemctl start pi-admin-app.service
  1. Check the status of the service:
sudo systemctl status pi-admin-app.service

pi-admin-app's People

Watchers

Salvatore Vitale avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.