Archivos estáticos de botella
He intentado leer los documentos de Bottle, sin embargo, todavía no estoy seguro de cómo funciona el servicio de archivos estáticos. Yo tengo unindex.tpl
archivo, y dentro de él tiene un archivo css adjunto, y funciona. Sin embargo, estaba leyendo que Bottle no sirve automáticamente los archivos css, lo que no puede ser cierto si la página se carga correctamente.
Sin embargo, me he topado con problemas de velocidad al solicitar la página. Es porque no usé elreturn static_file(params go here)
? Si alguien pudiera aclarar cómo funcionan y cómo se utilizan al cargar la página, sería genial.
Código del servidor:
<code>from Bottle import route,run,template,request,static_file @route('/') def home(): return template('Templates/index',name=request.environ.get('REMOTE_ADDR')) run(host='Work-PC',port=9999,debug=True) </code>
Índice:
<code><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <title>index</title> <link type="text/css" href="cssfiles/mainpagecss.css" rel="stylesheet"> </head> <body> <table style="width: 100%; text-align: left; margin-left: auto; margin-right: auto;" border="0" cellpadding="2" cellspacing="2"> <tbody> <tr> <td> <h1><span class="headertext"> <center>Network Website</center> </span></h1> </td> </tr> </tbody> </table> %if name!='none': <p align="right">signed in as: {{name}}</p> %else: pass %end <br> <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2"> <tbody> <tr> <td> <table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2"> <tbody> <tr> <td style="width: 15%; vertical-align: top;"> <table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"> <tbody> <tr> <td>Home<br> <span class="important">Teamspeak Download</span><br> <span class="important">Teamspeak Information</span></td> </tr> </tbody> </table> </td> <td style="vertical-align: top;"> <table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"> <tbody> <tr> <td> <h1><span style="font-weight: bold;">Network Website</span></h1> To find all of the needed information relating to the network's social capabilities, please refer to the links in the side bar.</td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </body> </html> </code>