1

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

Requirement 1

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.

Requirement 2

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

Requirement 3

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

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Hello, something is not clear to me. I read the doc and so far it seems that I need to keep running python/flask to have my production website running, what I am trying to achieve is to have a script that create the webpage index.hmtl and copy the file in my nginx web folder. the python script is just need to generate the index.html page in background and to update the index.html page every day when my server list change - thanks for your help
ah ok. In that case you need to create the script that generates the index.html and copies it to your public web folder. The script can run everyday by using a cronjob.
do you think python is the best solution for this or do you think this kind of script should be done by another tool? many thanks
it can be done in Python. I have done similar projects to yours. But if you want to accomplish your "requirements" you will also need to know a little bit of HTML and JavaScript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.