国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > Python > 正文

tornado框架blog模塊分析與使用

2020-02-23 04:59:22
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

代碼如下:
#!/usr/bin/env python
#
# Copyright 2009 Facebook
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

import markdown
import os.path
import re
import torndb
import tornado.auth
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
import unicodedata

from tornado.options import define, options
#定義一些通用的配置信息,比如數(shù)據(jù)庫(kù)的連接信息,端口信息
define("port", default=8888, help="run on the given port", type=int)
define("mysql_host", default="127.0.0.1:3306", help="blog database host")
define("mysql_database", default="blog", help="blog database name")
define("mysql_user", default="root", help="blog database user")
define("mysql_password", default="sa123", help="blog database password")

#定義Application信息,它是繼承tornado.web.Application 的
class Application(tornado.web.Application):
   # __init__ 函數(shù)自動(dòng)調(diào)用
    def __init__(self):
      #這里就是url對(duì)應(yīng)的控制器,下面分別對(duì)應(yīng)一個(gè)類(lèi),來(lái)處理里面的邏輯
        handlers = [
            (r"/", HomeHandler),
            (r"/archive", ArchiveHandler),
            (r"/feed", FeedHandler),
            (r"/entry/([^/]+)", EntryHandler),
            (r"/compose", ComposeHandler),
            (r"/auth/login", AuthLoginHandler),
            (r"/auth/logout", AuthLogoutHandler),
        ]
      #設(shè)置,如博客標(biāo)題,模板目錄,靜態(tài)文件目錄,xsrf,是否調(diào)試
        settings = dict(
            blog_title=u"Tornado Blog",
            template_path=os.path.join(os.path.dirname(__file__), "templates"),
            static_path=os.path.join(os.path.dirname(__file__), "static"),

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 江都市| 夏邑县| 永清县| 五华县| 彰化市| 策勒县| 楚雄市| 黑河市| 德兴市| 五指山市| 云浮市| 佛坪县| 清新县| 土默特右旗| 兴和县| 曲周县| 东乌珠穆沁旗| 新绛县| 滦平县| 蒙自县| 郓城县| 禹城市| 泰和县| 高陵县| 那坡县| 鄂托克前旗| 巴彦淖尔市| 鄱阳县| 左贡县| 泽普县| 武定县| 霸州市| 延庆县| 香河县| 日土县| 金川县| 垣曲县| 大悟县| 健康| 广州市| 平乡县|