at first, not sure if the javascript part makes any sense, just leave it. In addition, you open the p tag, but do not close it. Not sure what your template engine is, but you can just pass the variables in pure python. Also, be sure to include quotation marks around your link. So your code should look something like this:
class Server(object): _cp_config = { 'tools.sessions.on': True, 'tools.auth.on': True } auth = AuthController() @cherrypy.expose @require() def index(self): f = open ("file.txt","r") link = f.read() f.close() myText = "Hello World" html = """ <html> <body> <p>%s</p> <a href="%s" ><img src="images/go_online.png"></a> </body> </html> """ %(myText, link) return html index.exposed = True
(btw,% s are string placeholders that will be filled with the variables in% (firstString, secondString) at the end of the multi-line string.
source share