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
  WebElements of an HTML page Nik1811 2 264 Mar-14-2024, 12:39 PM
Last Post: Nik1811
  Take data from web page problem codeweak 5 859 Nov-01-2023, 12:29 AM
Last Post: codeweak
  Create simple live plot of stock data dram 2 2,856 Jan-27-2023, 04:34 AM
Last Post: CucumberNox
  Tkinterweb (Browser Module) Appending/Adding Additional HTML to a HTML Table Row AaronCatolico1 0 876 Dec-25-2022, 06:28 PM
Last Post: AaronCatolico1
  SMA (simple moving avg) Not receiving Data (stock prices). gdbengo 2 1,406 Jul-31-2022, 08:20 PM
Last Post: paulyan
  OCR-Python from Multi TIFF to HOCR getting only Data from 1st Page of multiple TIFF JOE 0 2,120 Feb-18-2022, 03:18 PM
Last Post: JOE
  open the html page from the django dropdown menu? shams 2 3,279 Jul-17-2021, 08:10 AM
Last Post: shams
  reading html and edit chekcbox to html jacklee26 5 3,020 Jul-01-2021, 10:31 AM
Last Post: snippsat
  Plotting sum of data files using simple code Laplace12 3 2,992 Jun-16-2021, 02:06 PM
Last Post: BashBedlam
  Using Local Html Data knight2000 2 1,929 Jun-07-2021, 06:59 AM
Last Post: knight2000

Forum Jump:

User Panel Messages

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