그놈의 안드로이드
Tornado 웹서버 구성 본문
import tornado.ioloop
import tornado.web
import pymysql
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | class Main(tornado.web.RequestHandler): def get(self): #key is key key = self.get_argument('key', None) #self.write(key) if key == 'big': top = "<html><body>" img = "<img src='uploads/big.jpg'>" bottom = "</body></html>" self.write(top+img+bottom) if key == 'small1': top = "<html><body>" img = "<img src='uploads/small1.jpg'>" bottom = "</body></html>" self.write(top+img+bottom) if key == 'small2': top = "<html><body>" img = "<img src='uploads/small2.jpg'>" bottom = "</body></html>" self.write(top+img+bottom) if key == 'text': conn = pymysql.connect( host="localhost", database="tn", user="root", password="1234") curs = conn.cursor(pymysql.cursors.DictCursor) sql = "select no, name from tn" curs.execute(sql) table = "" rows = curs.fetchall() for row in rows: table += str(row["name"]) top = "<html><body>" bottom = "</body></html>" self.write(top+table+bottom) application = tornado.web.Application([ (r"/", Main), (r"/uploads/(.*)", tornado.web.StaticFileHandler, { "path": "/uploads" }), ]) if __name__ == "__main__": application.listen(8888) tornado.ioloop.IOLoop.instance().start() | cs |
'리눅스 > 웹 서버' 카테고리의 다른 글
Nginx 아키텍처 (0) | 2019.01.01 |
---|---|
Lighttpd error code 500 (0) | 2018.12.31 |
Vert.x 웹서버 구성 (0) | 2018.12.30 |
Node.js 웹서버 구성 (0) | 2018.12.30 |
Netty 웹서버 구성 (0) | 2018.12.30 |