• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Server side, save settings

Q&A Forum › Category: Raspberry Pi › Server side, save settings
0 Vote Up Vote Down
Glen Brackett asked 4 years ago

I have and ESP32 and ESP8266 sending data via mqqt to Mosquito running on a RasperryPi. On the PI I have a web page and javaScript code displaying the mqqt data.
On the server side I want to save some setting for the webpage, IP, port, etc in a simple .json file or text file. I have been searching the web for a example but can’t seem to find what I am looking for. I am not sure if I need to switch to PHP, or can do something simple in JavaScript or some other way. 
Can someone point me in the right direction? 
Thank, Glen

4 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hello Glenn, You can handle JSON files with PHP or Javascript both options will accomplish the same task.
Which one are you already most familiar with?
Regards.
Sara

0 Vote Up Vote Down
Glen Brackett answered 4 years ago

That would be JavaScript. In reading about both, seems like PHP is what I want. What I’ve read so far is that JavaScript would save a file on the local computer, not the server which is the direction I think I am looking for.
The overall process I am trying to obtain is not “hard coding” items in the JavaScript of my webserver code.
 
Glen

0 Vote Up Vote Down
Steve Mercer answered 4 years ago

If you are more comfortable with Javascript and don’t want to learn PHP there is server side javascript called Node.js. You can save a file with JSON or integrate MySQL database with Node.js easily.

0 Vote Up Vote Down
Rui Santos Staff answered 4 years ago

@Glen Brackett, as @Steve Mercer suggested you have two options:

  • PHP (server side)
  • Node.js – JavaScript (server side)

You can convert variables or format them in JSON format using PHP:

  • https://www.w3schools.com/php/php_json.asp

Then, you can using the PHP file_put_contents() Function to create a JSON file:

  • https://www.w3schools.com/php/func_filesystem_file_put_contents.asp

I don’t have any guides on that exact topic, but if you get started by encoding/decoding variable into JSON, then store/read them from a JSON file, you should be able to do it.

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.