如何在服务器应答HTTP中引入python int

2024-04-19 22:47:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我必须创建一个HTTP服务器,用一个指向我的页面的链接来回答我的问题。当我执行HTTP请求时,这个链接必须是不同的,所以我使用random.randint(a,b)来生成一个random int,但是我不知道如何将它集成到HTML中。我的代码片段

        recvSocket.send("HTTP/1.1 200 OK\r\n\r\n" +
                    "<html>" +
                    "<head><title>Random URL - SAT - David Manso dmanso</title></head>" +
                    "<body>" +
                    "<h1>Hola.</h1>" +
                    "<h4>Dame otra</h4>" +
                    random.randint(123456789,987654321) +
                    "</body></html>" +
                    "\r\n")
    recvSocket.close()

Tags: 服务器httptitle链接htmlbodyrandom页面