Reputation: 103
I am new in programming and I have a project in mind but didn't find the answer yet by googling. So I am requesting some help from the python Gurus
I have a text file server.txt with list of servers and information separated by comma:
$ cat server.txt
server1, windows, 120, running
server2, linux, 250, offline
server3, centos, 60, maintenance
server4, windows, 123, running
server5, linux, 145, offline
server6, centos, 200, maintenance
server7, windows, 567, running
server8, linux, 890, offline
server9, centos, 456, maintenance
server10, windows, 345, running
server11, linux, 234, offline
server12, centos, 123, maintenance
server13, windows, 678, running
server14, windows, 120, running
server15, linux, 250, offline
server16, centos, 60, maintenance
server17, windows, 123, running
server18, linux, 145, offline
server19, centos, 200, maintenance
server20, windows, 567, running
server21, linux, 890, offline
server22, centos, 456, maintenance
server23, windows, 345, running
server24, linux, 234, offline
server25, centos, 123, maintenance
I need a python script to read the server.txt file with a cronjob and to generate a dynamic nice html table showing only the server name in a 7 columns table to have something like:
| server1 | server2 | server3 | server4 | server5 | server6 | server7 |
| server8 | server9 | server10 | server11 | server12 | server13 | server14 |
| server15 | server16 | server17 | server18 | server19 | server20 | server21 |
| server22 | server23 | server24 | server25 |
PS: I cannot post picture but any good table format is welcome :)
the idea will be that if I delete or add new server in the list the html table is automatically updated.
now another requirement will be that depending on some condition in the server.txt file the box in the table has different colors:
running => green
offline => red
maintenance => orange
and again the color should be automatically be updated when the server.txt file condition is changed
when moving the mouse on the table a small pop up windows should give the remaining information:
servername
os
free_space_in_GB
so you can see something like below by moving the mouse's cursor to the server1:
server1
windows
120GB
I really want to understand all the step for this dynamic HTML page creation with python so if you can explain the step will be perfect
Upvotes: 1
Views: 3438
Reputation: 128
You can use Flask, which is an easy framework for handling all the steps needed to go from file to dynamic website.
Flask is well documented and there are many tutorials for simple projects as yours.
Upvotes: 2