招聘的前端的编写
main.py
#!/bin/python #coding=utf-8 import tornado.ioloop import tornado.web,pymongo,datetime class BaseHandler(tornado.web.RequestHandler): def today(self): date=datetime.datetime.now() year=str(date.year)[-2:] month=str(date.month) day=str(date.day) return year+'-'+month+'-'+day class MainHandler(BaseHandler): def getData(self): collection=pymongo.Connection('localhost',27017).job.list return collection.find({'time':self.today()},{'_id':0}).sort("weight",pymongo.DESCENDING) def get(self): self.render('index.html',jobList=self.getData()) application = tornado.web.Application([ (r"/", MainHandler), (r"/favicon\.ico", tornado.web.StaticFileHandler,{'path':'./'}), (r'/imgs/(.*)',tornado.web.StaticFileHandler,{'path':'./imgs'}), (r'/js/(.*)',tornado.web.StaticFileHandler,{'path':'./js'}), ],debug=True) if __name__ == "__main__": application.listen(9000) tornado.ioloop.IOLoop.instance().start()
index.html(这段时间的前端编写不是白学的。呵呵)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <style> body{ background-color:white; } a{ text-decoration:none; } li{ color:#3a87ad; background-color:#d9edf7; margin:10px; list-style:none; width:600px; height:30px; padding:20px; border-left:5px #bce8f1 solid; } .content{ width:800px; margin:0 auto; } </style> <div class="content"> <ul> {%for i in jobList%} <a href="{{i['url']}}" target="_blank"><li>{{i['occupy']}}</li> {%end%} </ul> </div> </body> </html>
挺好玩的,过滤部分有待加强,而且可以加入个人喜欢的button就更好玩了,有时间在改吧