0

Disclaimer: I am not good at understanding http requests, so please bear with me

I am trying to change the content of an html web page whenever an http GET/POST request is made. It would work something like this:

What I want to accomplish

When my phone is charging, it is going to send an http request to the web server. The web server is going to change the content of the webpage to say something like "Phone is charging."

What I've done so far

I managed to send an HTTP request from my phone to the server every time the phone connects to a charger, I just don't know what to do with the http request that arrives to the server.

Thanks ahead of time!

EDIT: I figured out, according to @LawrenceCherone (thanks Lawrence!) that I can't do this with a static html page and just nginx. He said that I have to use a scripting language. Does bash work for this? Or should I learn something like python, PHP or something else?

I can't find any tutorials online for what I am trying to accomplish for some reason. Haven't seen any tutorials on how to 'react' to a POST request

Adriel Sand
  • 100
  • 1
  • 2
  • 13
  • what scripting language are you using? It cant be done with just static .html file and nginx – Lawrence Cherone Sep 19 '21 at 09:32
  • @LawrenceCherone I honestly have no clue, if a bash script could be run, that would be perfect honestly. I just have an html page (static) for now. – Adriel Sand Sep 19 '21 at 09:33
  • with apache you can write a cgi script in bash, with nginx I don't know if it support rfc3875 (https://datatracker.ietf.org/doc/html/rfc3875) – Lety Sep 20 '21 at 10:08
  • @Lety I don't mind using apache, I just put nginx as an example – Adriel Sand Sep 20 '21 at 10:10
  • these pages could help https://stackoverflow.com/questions/52242133/how-to-get-file-from-post-data-in-bash-cgi-script/52363117 and http://httpd.apache.org/docs/current/howto/cgi.html. To view environment variable available use env command in your cgi script. – Lety Sep 22 '21 at 09:39

0 Answers0