Tell me if there is a ready-made algorithm, according to the following task, otherwise I myself did not understand how to os.listdir("/news") through the while list of articles obtained by the os.listdir("/news") method, os.listdir("/news") don’t understand how to substitute the values obtained in the cycle as pages. There is a news folder ( /news ) in this folder of the html page ( 1.html , 2.html , etc.).
Home ( index.cgi ) is a cgi python script. C content of the form:
print """ ........ <div id="news1"> %s </div> <div id="news2"> %s</div> <div id="news3> %s </div> <div id="nav_news"> %s </div> ......... """ % (last_news, last_news-1, last_news-2, links) It is necessary to display the last three news from the folder on the main page (for example, if there is news 8, then the first news is the content of the page 8.html , the second news is the content of the page 7.html , the 3rd news is the content of the page 6.html ). Next, generate a link to the second page (for the div block with id="nav_news" ) and place news from the 5.html , 4.html , 3.html files on the second page. Next, generate a link to the third page and place news on it in div blocks with id="news1" and news2 - 2.html and 1.html respectively. And so on generate links depending on how much news in the folder.