Pliki statyczne butelki
Próbowałem czytać dokumenty do Bottle, jednak nadal nie jestem pewien, jak działa obsługa plików statycznych. mamindex.tpl
plik, do którego dołączony jest plik css i działa. Czytałem jednak, że Bottle nie obsługuje automatycznie plików css, co nie może być prawdą, jeśli strona ładuje się poprawnie.
Poprosiłem o problemy z szybkością podczas żądania strony. Czy to dlatego, że nie korzystałem zreturn static_file(params go here)
? Gdyby ktoś mógł wyjaśnić, jak działają i jak są one używane podczas ładowania strony, byłoby świetnie.
Kod serwera:
<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>
Indeks:
<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>