Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Manufacturing Technology >> Industrial Technology

Effortlessly Serve Static Files with Go: A Proven Approach

The embedded datalogger is a wonderful tool to create databases of your process-data. The Notification manager and logger on the other hand is perfect to log user-actions or specific events. You can create your own notifications by modifying the example on GitHub.

In development or even sometimes in production you don’t want to struggle with logging in to the sFTP server and copying the files every time you wan’t to check your data or new logs. This blog will show you how to create a static file-server with GoLang to serve the files you need by simply browsing the right URI.

More information about using Go on PLCnext can be found in a previous blog entry.  In this blog we’ll use only one command to build our code for the AXC F 1152 or AXC F 2152.

The source-code for our fileserver is rather short and can be found here.

Copy the sourcefile to your development machine and open a terminal. Browse to the right directory and run the following command.

env GOOS=linux GOARCH=arm GOARM=7 go build serve.go

You should get a new file, this new file is our fileserver!

Copy the file to the controller via WinSCP and open a SSH connection.
Make the file (binary) executable with

chmod +x serve

and start the fileserver with

./serve

To download the default logfile you can browse and the file should be downloaded in the browser.http://#IpOfController:4000/logs/default.sqlite


Industrial Technology

  1. File Cabinet: Design, Manufacturing, and Modern Use
  2. C File Handling: Mastering I/O with fopen, fprintf, fread, and fseek
  3. Mastering High‑Quality STL Export Settings for Precise 3D Printing
  4. Mastering C File I/O: Create, Open, Read, Write, and Close Files with Confidence
  5. Understanding C Header Files: Types, Usage, and Best Practices
  6. Build Electrical Panels Quickly with CAE E3.series: A Step‑by‑Step Guide
  7. Create Electrical Schematics Quickly with CAE E3.series: A Step‑by‑Step Guide
  8. Using Polyurethane Coatings to Safely Dissipate Static and Prevent ESD Damage
  9. Create a CAD File for Legacy Parts: A Step‑by‑Step Guide
  10. What Is a Mill File? Your Comprehensive Guide to the Essential Wood & Metalworking Tool