Python Forum
simple html page with update data
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
simple html page with update data
#1
hello,
need yor help with a simple project ,
I have lighttpd running on my PI and I want to create a webpage with python that will show me updated data from sensors on my PI (and all kind of python code output I'm running)

what will be the best way to make it?

Thanks,
Reply
#2
Flask works fine for this.
Here some links from me link1, link2 , link3
Python WebServer With Flask and Raspberry Pi
Just so you know Flask comes with build in web-server,so can develop everything without lighttpd.
If need to make public on web then need to use a production web-server,then Gunicorn can be better choice than lighttpd.
As there are really good tutorials for this How To Serve Flask Applications with Gunicorn and Nginx on Ubuntu 20.04
Reply
#3
no need for public
this is just for my home private netwrok

no other solution because I'm allready using lighttpd for pi-hole?
or it's best not to mix apps?


Thanks ,
Reply
#4
Flask is 100% the best go to here.

If you do something such as:

from flask import Flask

app = Flask(__name__)
@app.route('/')
def home():
    a = 100 + 100
    return a
Then that will show 200 on your webpage in basic text (I think it shows it in HTML's paragraph font/size but can't remember off the top of my head). The URL would be "www.mydomain.com/" aka the Index page or home page, if you wanted to have multiple pages, you can change the "@app.route('/')" to whatever you want it to be, for example if you had a page describing the characteristics of owls, you could do "@app.route('/owls')".

If you link it up to a database, you can then use SQLAlchemy to connect to the DB and the site can be built to automatically update based on the info in the DB. So instead of having to mess with the code, you'd just refresh the page and bam!
while dad_has_cigs == True:
    happiness = True
    if dad_has_cigs == False:
    print("Dad come home!")
    happiness = not happiness
    break
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  open the html page from the django dropdown menu? shams 2 1,251 Jul-17-2021, 08:10 AM
Last Post: shams
  reading html and edit chekcbox to html jacklee26 5 1,111 Jul-01-2021, 10:31 AM
Last Post: snippsat
  Plotting sum of data files using simple code Laplace12 3 1,244 Jun-16-2021, 02:06 PM
Last Post: BashBedlam
  Using Local Html Data knight2000 2 761 Jun-07-2021, 06:59 AM
Last Post: knight2000
  Suggestions for a simple data analysis program t4keheart 0 814 Mar-08-2021, 03:45 PM
Last Post: t4keheart
Question Python + Google Sheet | Best way to update specific cells in a single Update()? Vokofe 1 938 Dec-16-2020, 05:26 AM
Last Post: Vokofe
  Extract data from PDF page to Excel nathan_nz 1 818 Oct-29-2020, 08:04 PM
Last Post: Larz60+
  html, python, a simple form test 1 901 Aug-09-2020, 01:59 PM
Last Post: snippsat
  HTML to Python to Windows .bat and back to HTML perfectservice33 0 1,151 Aug-22-2019, 06:31 AM
Last Post: perfectservice33
  Create simple live plot of stock data dram 1 1,618 May-28-2019, 06:24 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020