91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

beeblog創建博客

發布時間:2020-07-25 10:36:06 來源:網絡 閱讀:996 作者:1350368559 欄目:開發技術

1、定義modles.go

這里需要提前get一些包,否則會提示找不到哦,
models/models.go:5:2:

go get github.com/mattn/go-sqlite3
go get github.com/unknwon/com

package models

import (
    "os"
    "path"
    "time"

    "github.com/astaxie/beego/orm"
    _ "github.com/mattn/go-sqlite3"
    "github.com/unknwon/com"
)

const (
    _DB_NAME         = "data/beeblog.db"
    _SQLLITE3_DRIVER = "sqlite3"
)

type Categeory struct {
    Id              int64
    Title           string
    Created         time.Time `orm:"index"`
    views           int64     `orm:"index"`
    TopicTime       time.Time `orm:"index"`
    TopicCount      int64
    TopicLastUserId int64
}

type Topic struct {
    Id              int64
    Uid             int64
    Title           string
    Content         string `orm:"size(5000)"`
    Attachment      string
    Created         time.Time `orm:"index"`
    Updated         time.Time `orm:"index"`
    views           int64     `orm:"index"`
    Author          string
    ReplyTime       time.Time `orm:"index"`
    ReplyCount      int64
    ReplyLastUserId int64
}

func RegisterDB() {
    if !com.IsExist(_DB_NAME) {
        os.MkdirAll(path.Dir(_DB_NAME), os.ModePerm) //創建/a/b/c/d目錄
        os.Create(_DB_NAME)                          //數據庫文件不存在的時候會自動創建
    }
    orm.RegisterModel(new(Categeory), new(Topic))                   //注冊模型
    orm.RegisterDriver(_SQLLITE3_DRIVER, orm.DRSqlite)              //注冊驅動
    orm.RegisterDataBase("default", _SQLLITE3_DRIVER, _DB_NAME, 10) //注冊默認數據庫
}

2 定義home.html 前端的頁面

這里需要下載bootsstrap文件到static文件下 https://github.com/twbs/bootstrap/releases/download/v3.3.7/bootstrap-3.3.7-dist.zip

<!DOCTYPE html>
<html>
  <head>
    <title>首頁 - 我的beego博客</title>>
    <link rel="short icon" href="/static/img/favicon.png">
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
  </head>

  <body>
    <div class="navbar navbar-default navbar-fixed-top">
      <div class="container">
        <a class="navbar-brand" href="/">我的博客</a>
        <ul class="nav navbar-nav">
          <li class="active"><a href="/">首頁</a></li>
          <li><a href="/category">分類</a></li>
          <li><a href="/topic">文章</a></li>
        </ul>
      </div>    
    </div>
  </body>
</html>

3 定義main.go

package main

import (
    "beeblog/models"
    _ "beeblog/routers"

    "github.com/astaxie/beego"
    "github.com/astaxie/beego/orm"
)

func init() {
    models.RegisterDB()
}

func main() {
    orm.Debug = true                      //debug在開發模式下設置為true
    orm.RunSyncdb("default", false, true) //必須有一個數據庫名字叫default,false表示不是每次都刪除重建表,首次建表即可,true表示打印建表信息
    beego.Run()
}

執行:bee run beeblog

beeblog

2018/07/31 16:18:19 SUCCESS  ? 0006 Built Successfully!
2018/07/31 16:18:19 INFO     ? 0007 Restarting 'beeblog'...
2018/07/31 16:18:19 SUCCESS  ? 0008 './beeblog' is running...
create table `categeory`
    -- --------------------------------------------------
    --  Table Structure for `beeblog/models.Categeory`
    -- --------------------------------------------------
    CREATE TABLE IF NOT EXISTS `categeory` (
        `id` integer NOT NULL PRIMARY KEY AUTOINCREMENT,
        `title` varchar(255) NOT NULL DEFAULT '' ,
        `created` datetime NOT NULL,
        `topic_time` datetime NOT NULL,
        `topic_count` integer NOT NULL DEFAULT 0 ,
        `topic_last_user_id` integer NOT NULL DEFAULT 0
    );
    CREATE INDEX `categeory_created` ON `categeory` (`created`);
    CREATE INDEX `categeory_topic_time` ON `categeory` (`topic_time`);

create table `topic`
    -- --------------------------------------------------
    --  Table Structure for `beeblog/models.Topic`
    -- --------------------------------------------------
    CREATE TABLE IF NOT EXISTS `topic` (
        `id` integer NOT NULL PRIMARY KEY AUTOINCREMENT,
        `uid` integer NOT NULL DEFAULT 0 ,
        `title` varchar(255) NOT NULL DEFAULT '' ,
        `content` varchar(5000) NOT NULL DEFAULT '' ,
        `attachment` varchar(255) NOT NULL DEFAULT '' ,
        `created` datetime NOT NULL,
        `updated` datetime NOT NULL,
        `author` varchar(255) NOT NULL DEFAULT '' ,
        `reply_time` datetime NOT NULL,
        `reply_count` integer NOT NULL DEFAULT 0 ,
        `reply_last_user_id` integer NOT NULL DEFAULT 0
    );
    CREATE INDEX `topic_created` ON `topic` (`created`);
    CREATE INDEX `topic_updated` ON `topic` (`updated`);
    CREATE INDEX `topic_reply_time` ON `topic` (`reply_time`);

2018/07/31 16:18:19.789 [I] [asm_amd64.s:2337] http server Running on http://:8080
2018/07/31 16:18:41.650 [D] [server.go:2619] ::1 - - [31/Jul/2018 04:18:41] "GET / HTTP/1.1 200 0" 0.005279  Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36

2018/07/31 16:18:41.667 [D] [server.go:2619] ::1 - - [31/Jul/2018 04:18:41] "GET /static/css/bootstrap.min.css HTTP/1.1 200 0" 0.002514 http://localhost:8080/ Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36

2018/07/31 16:18:43.342 [D] [server.go:2619] ::1 - - [31/Jul/2018 04:18:43] "GET /category HTTP/1.1 404 0" 0.003407 http://localhost:8080/ Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36

beeblog
2018/07/31 16:23:05 SUCCESS  ? 0009 Built Successfully!
2018/07/31 16:23:05 INFO     ? 0010 Restarting 'beeblog'...
2018/07/31 16:23:05 SUCCESS  ? 0011 './beeblog' is running...
table `categeory` already exists, skip //這里表已經存在,跳過創建
table `topic` already exists, skip
2018/07/31 16:23:05.792 [I] [asm_amd64.s:2337] http server Running on http://:8080
2018/07/31 16:24:34.034 [D] [server.go:2619] ::1 - - [31/Jul/2018 04:24:34] "GET / HTTP/1.1 200 0" 0.011260  Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36

瀏覽器訪問:http://localhost:8080/
beeblog創建博客

修改home.html

<!DOCTYPE html>
<html>
  <head>
    <title>首頁 - 我的beego博客</title>>
    <link rel="short icon" href="/static/img/favicon.png">
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
  </head>

  <body>
    <div class="navbar navbar-default navbar-fixed-top">
      <div class="container">
        <a class="navbar-brand" href="/">我的博客</a>
        <ul class="nav navbar-nav">
          <li class="active"><a href="/">首頁</a></li>
          <li><a href="/category">分類</a></li>
          <li><a href="/topic">文章</a></li>
        </ul>
      </div>    
    </div>
    <div class="container">
      <div class="page-header">
        <h2>我的第一篇博客</h2>
        <h7 class="text-muted">文章發表于2018年7月31日XX時XX分,共有100次瀏覽,200個評論</h7>
        <p>大家好,這是我的第一篇博客,這里是博客內容,謝謝查看</p>
      </div>
    </div>
  </body>
</html>

瀏覽器訪問:http://localhost:8080/
beeblog創建博客

4 如果使用js或者jquery,在home.html加上兩行:

其中,jquery使用的是七牛云存儲提供的jquery地址,查詢jquery地址:http://www.staticfile.org/

<!DOCTYPE html>
<html>
  <head>
    <title>首頁 - 我的beego博客</title>>
    <link rel="short icon" href="/static/img/favicon.png">
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
  </head>

  <body>
    <div class="navbar navbar-default navbar-fixed-top">
      <div class="container">
        <a class="navbar-brand" href="/">我的博客</a>
        <ul class="nav navbar-nav">
          <li class="active"><a href="/">首頁</a></li>
          <li><a href="/category">分類</a></li>
          <li><a href="/topic">文章</a></li>
        </ul>
      </div>    
    </div>
    <div class="container">
      <div class="page-header">
        <h2>我的第一篇博客</h2>
        <h7 class="text-muted">文章發表于2018年7月31日XX時XX分,共有100次瀏覽,200個評論</h7>
        <p>大家好,這是我的第一篇博客,這里是博客內容,謝謝查看</p>
      </div>
    </div>
     <script type="text/javascript" src="https://cdn.staticfile.org/jquery/2.0.3/jquery.min.js"></script>
     <script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
  </body>
</html>

博客的分類和登陸

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

晋宁县| 灌云县| 海宁市| 都昌县| 虞城县| 高州市| 胶南市| 鄂温| 云梦县| 揭西县| 武强县| 广南县| 罗田县| 江川县| 万山特区| 奈曼旗| 临澧县| 禄劝| 嵊州市| 社旗县| 屏山县| 玉溪市| 水富县| 巴南区| 囊谦县| 卓资县| 股票| 广州市| 兖州市| 丹棱县| 弋阳县| 哈尔滨市| 饶阳县| 富民县| 阿城市| 青龙| 涪陵区| 孙吴县| 石泉县| 樟树市| 东城区|