動機
Juliaが好きだから
目標
Genie.jlのハローワールドをやる,つまり
/helloに「Hello World!」の表示
作業環境
今回の環境(atomにJuno入れてます,Ubuntu18.04)
julia> versioninfo() Julia Version 1.1.0 Commit 80516ca202 (2019-01-21 21:24 UTC) Platform Info: OS: Linux (x86_64-pc-linux-gnu) CPU: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-6.0.1 (ORCJIT, skylake) Environment: JULIA_EDITOR = atom -a JULIA_NUM_THREADS = 4 JULIA_REVISE = auto
Genie.jlについて
公式によると(http://genieframework.com/)
The highly productive Julia web framework
Genie is a full-stack MVC web framework that promotes a streamlined and efficient workflow for developing modern web applications.
らしいです
公式レポジトリのログを見ると,頻繁に更新されているようです
Genieの作者のAdrian Salceanu様はバルセロナのJuliaユーザーグーループのオーガナイザのようで,最近
Julia Programming Projects: Learn Julia 1.x by building apps for data analysis, visualization, machine learning, and the web (English Edition)などの本を出版されています
(まだ読んでる途中なので,後日レビューします)
ご本人のJuliacon登壇動画によると
"Like Django and Rails, but without the fails..."
だそうです
良さそうですね
MVCモデルとは
Model:ビジネスロジックを担当
View:表示,入出力担当
Controller:ユーザーの入力に基づき,ModelとViewを制御
が揃っていて、それぞれ役割を分割してコーディングするモデルを指すようです
Genieのインストールとサーバーの起動
julia>
]を押す,するとJuliaのヴァージョン管理ツールpkgのモードに入る,]は表示されない
pkg>
0212という名前の仮想環境を作って、入る
(conda create -n 0212して、sour activate 0212するような)
pkg>activate 0212
Genieのインストール
(0212) pkg>add https://github.com/essenciary/Genie.jl
Backspaceでpkgモードを抜けて,Genieを使う宣言をする
julia>using Genie
;(セミコロン)でshellモードに入って,0212に入る
shell>cd 0212
Backspaceでshellモードを抜けて test_appという名前で作成して、起動
julia>Genie.REPL.new_app("test_app") julia>Genie.AppServer.startup()
http://localhost:8000 にアクセス
Genie Hello World
test_appの構造を見てみる
shell> tree test_app test_app ├── LICENSE.md ├── Manifest.toml ├── Project.toml ├── README.md ├── app │ ├── assets │ │ ├── css │ │ │ └── application.css │ │ ├── fonts │ │ └── js │ │ ├── application.js │ │ └── channels.js │ ├── helpers │ │ ├── ValidationHelper.jl │ │ └── ViewHelper.jl │ ├── layouts │ │ └── app.jl.html │ └── resources ├── bin │ ├── repl │ └── server ├── build ├── cache ├── config │ ├── database.yml │ ├── env │ │ ├── dev.jl │ │ ├── prod.jl │ │ └── test.jl │ ├── global.jl │ ├── initializers │ │ ├── converters.jl │ │ └── searchlight.jl │ ├── routes.jl │ └── secrets.jl ├── db │ ├── migrations │ └── seeds ├── docs │ ├── make.jl │ ├── mkdocs.yml │ └── src │ └── index.md ├── env.jl ├── genie.jl ├── lib ├── log │ └── dev.log ├── package.json ├── public │ ├── css │ │ ├── bootstrap-theme.css │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap.css │ │ ├── bootstrap.min.css │ │ ├── dosis-font.css │ │ ├── prism.css │ │ ├── style.css │ │ └── themify-icons.css │ ├── error-404.html │ ├── error-500.html │ ├── favicon.ico │ ├── favicon.png │ ├── fonts │ │ ├── dosis │ │ │ ├── 3isE9muMMOq1K7TQ7HkKvIDGDUGfDkXyfkzVDelzfFk.woff2 │ │ │ ├── O6SOu9hYsPHTU43R17NS5XYhjbSpvc47ee6xR_80Hnw.woff2 │ │ │ ├── RPKDmaFi75RJkvjWaDDb0nYhjbSpvc47ee6xR_80Hnw.woff2 │ │ │ ├── VK-RlLrn4NFhRGqPkj6IwBkAz4rYn47Zy2rvigWQf6w.woff2 │ │ │ └── oaBFj7Fz9Y9_eW3k9Jd9X6CWcynf_cDxXwCLxiixG1c.woff2 │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ ├── glyphicons-halflings-regular.woff2 │ │ ├── themify.eot │ │ ├── themify.svg │ │ ├── themify.ttf │ │ └── themify.woff │ ├── img │ │ ├── community.png │ │ ├── contribute-2.png │ │ ├── docs.png │ │ ├── genie-sad.png │ │ └── genie.png │ ├── js │ │ ├── ansi_up.js │ │ ├── ansi_up.js.map │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ ├── jquery.easing.min.js │ │ ├── jquery.min.js │ │ ├── jquery.min.map │ │ ├── prism.js │ │ ├── scrolling-nav.js │ │ ├── static.js │ │ └── validator.js │ ├── robots.txt │ └── welcome.html ├── session ├── src │ ├── App.jl │ └── Toolbox.jl ├── task ├── test │ └── test_config.jl └── webpack.config.js 31 directories, 76 files
JULIA_EDITORで指定したエディタでconfig内のroutes.jlを編集する
julia>edit("config/routes.jl")
(私の場合)atomが開いて、route.jlが開く
using Genie.Router route("/") do serve_static_file("/welcome.html") end
ページを足して、Hello World!を表示させるために,routes.jlに次を追記
route("/hello") do "Hello World!" end
http://localhost:8000/hello
にアクセス
感想等
次回は認証とかやろうと思います
参考にしたURL,書籍
MVCモデルについて--qiita
Genie.jl--Github
Julia Programming Projects: Learn Julia 1.x by building apps for data analysis, visualization, machine learning, and the web (English Edition)
日本語版