I am new to Python and programming in general. I use a web server called Tornado to "host" my sites. Whenever I use self.render ("example.html", variables here) to create a dynamic html page, the created html page does not contain CSS, because it just creates an html page without improving the CSS style, even if I placed his .css file along with the example.html page in the same "Tornado / template" folder. Pretty sure I got the html link for the CSS tag too.
If I open example.html with a browser and not with Tornado, it will "render" with a .css file.
Since I donβt know why this is happening, I will just post all my code here: This is the app.py application in Tornado:
import config import os.path import re import MySQLdb import tornado.ioloop import tornado.web class MainHandler(tornado.web.RequestHandler): def get(self): self.render("question3.html") class StopTornado(tornado.web.RequestHandler): def get(self): tornado.ioloop.IOLoop.instance().stop() class ReturnQuery(tornado.web.RequestHandler): def post(self): connection = MySQLdb.connect(**config.mysql_config) cursor = connection.cursor() if 'lowermass' in self.request.arguments and 'uppermass' in self.request.arguments: lowermass = self.get_argument('lowermass') uppermass = self.get_argument('uppermass')
And this is the html page I'm trying to do:
So basically, I get two integer inputs from another html page from the web user, and the mysql query is executed on app.py above in the database. It returns a list (I think this is a list of lists) of all the results, and I use the data to populate the table in the html page below, but it is an html page containing a table that will not be "displayed" using css.
lowermass and uppermass are user inputs (must be int). question3.html is the html page for user input, and question2.html is the html page with the table.
I seriously hope this is just a dumb mistake that I can quickly fix.
<html> <head> <link rel = "stylesheet" type ="text/css" href = "presnt.css"> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js"></script> <script src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script> <script> $(document).ready(function(){ $('#table').dataTable(); }); </script> <title>Birds with body mass in range</title> <div id = "header"> Birds with body mass in range </div> <br> </head> <body> <table id = "table"> <thead> <tr> <td style="padding:4px;border-top:1px solid black;">rownum</td> <td style="padding:4px;border-top:1px solid black;">common name</td> </tr> <tr> <td style = "padding:1px;border-top:1px solid black;"> </td> <td style = "padding:1px;border-top:1px solid black;"> </td> </tr> </thead> <tbody> {% if birds %} {% for bird in birds %} <tr> <td>{{ bird[0] }} </td> <td>{{ bird[1] }}</td> </tr> {% end %} {% else %} <tr> <td colspan = 2> No results returned</td> </tr> {% end %} </tbody> </table> </body>
source share