golang web 框架 beego学习笔记
2023-03-04 本文已影响0人
jiaxiaolei
[root@slte1xzb1cf jia_beego]# go get github.com/beego/beego/v2
[root@slte1xzb1cf jia_beego]# go get github.com/beego/bee/v2
[root@slte1xzb1cf jia_beego]# bee new pro01
2023/03/05 21:56:08 INFO ▶ 0001 Getting bee latest version...
2023/03/05 21:56:08 WARN ▶ 0002 Update available 1.12.0 ==> 2.0.4
2023/03/05 21:56:08 WARN ▶ 0003 Run `bee update` to update
2023/03/05 21:56:08 INFO ▶ 0004 Your bee are up to date
2023/03/05 21:56:08 INFO ▶ 0005 generate new project support go modules.
2023/03/05 21:56:08 INFO ▶ 0006 Creating application...
create /root/jia_study_golang/jia_beego/pro01/go.mod
create /root/jia_study_golang/jia_beego/pro01/
create /root/jia_study_golang/jia_beego/pro01/conf/
create /root/jia_study_golang/jia_beego/pro01/controllers/
create /root/jia_study_golang/jia_beego/pro01/models/
create /root/jia_study_golang/jia_beego/pro01/routers/
create /root/jia_study_golang/jia_beego/pro01/tests/
create /root/jia_study_golang/jia_beego/pro01/static/
create /root/jia_study_golang/jia_beego/pro01/static/js/
create /root/jia_study_golang/jia_beego/pro01/static/css/
create /root/jia_study_golang/jia_beego/pro01/static/img/
create /root/jia_study_golang/jia_beego/pro01/views/
create /root/jia_study_golang/jia_beego/pro01/conf/app.conf
create /root/jia_study_golang/jia_beego/pro01/controllers/default.go
create /root/jia_study_golang/jia_beego/pro01/views/index.tpl
create /root/jia_study_golang/jia_beego/pro01/routers/router.go
create /root/jia_study_golang/jia_beego/pro01/tests/default_test.go
create /root/jia_study_golang/jia_beego/pro01/main.go
2023/03/05 21:56:08 SUCCESS ▶ 0007 New application successfully created!
[root@slte1xzb1cf jia_beego]# cd pro01/
[root@slte1xzb1cf pro01]# ls
conf controllers go.mod main.go models routers static tests views
[root@slte1xzb1cf pro01]# go mod tidy
go: downloading github.com/smartystreets/goconvey v1.6.4
go: downloading github.com/elazarl/go-bindata-assetfs v1.0.0
go: downloading gopkg.in/yaml.v2 v2.2.1
go: downloading golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
go: downloading gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
go: downloading github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d
go: downloading github.com/jtolds/gls v4.20.0+incompatible
go: downloading github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1
go: downloading golang.org/x/net v0.0.0-20190620200207-3b0461eec859
go: downloading golang.org/x/text v0.3.0
go: finding module for package github.com/shiena/ansicolor
go: found github.com/shiena/ansicolor in github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18
[root@slte1xzb1cf pro01]# vim conf/app.conf
[root@slte1xzb1cf pro01]# bee run
______
| ___ \
| |_/ / ___ ___
| ___ \ / _ \ / _ \
| |_/ /| __/| __/
\____/ \___| \___| v1.12.0
2023/03/05 21:59:05 WARN ▶ 0001 Running application outside of GOPATH
2023/03/05 21:59:05 INFO ▶ 0002 Using 'pro01' as 'appname'
2023/03/05 21:59:05 INFO ▶ 0003 Initializing watcher...
2023/03/05 21:59:07 SUCCESS ▶ 0004 Built Successfully!
2023/03/05 21:59:07 INFO ▶ 0005 Restarting 'pro01'...
2023/03/05 21:59:07 SUCCESS ▶ 0006 './pro01' is running...
2023/03/05 21:59:07.411 [I] [asm_amd64.s:1581] http server Running on http://:8082
image.png
扩展阅读
Sinatra 微型 Web 框架 (Ruby)
https://www.oschina.net/p/sinatra?hmsr=aladdin1e1
简介:
软件简介
Sinatra:一个优雅地包装了 Web 开发的 DSL
你相信用 100 行代码可以实现一个博客吗?用 Sinatra 框架就可以做到。下面就是这样子的一个 Web 应用:
Reprise - A Minimalistic Blog
这个应用的代码:点这里查看
一个简单的 hello world 的 web 应用要写多少代码?用 Sinatra 只需 5 行代码:
require 'rubygems'
require 'sinatra'
get '/' do
'Hello World'
end
安装方法:
ruby -rubygems hi.rb
sinatra/sinatra
https://github.com/sinatra/sinatra
简介:
Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort: