一个Web Application其实就是Erlang OTP中的一个Application,这个Application我们可以通过脚本来进行创建.
包含下面的内容:
- html模板文件(包含html,css,image,通常位于/wwwroot/目录下)
- erl页面代码(包含myapp.app, *.erl文件,通常位于/src/目录下)
- start.sh启动脚本(用来启动本应用,实质是调用erl启动Application)
Nitrogen默认的路径映射规则,是将 /
转化为 _
,比如:
http://domain/web/user
对应的页面文件为 web_user.erl
用户也可以通过定义myapp:route/1函数,定义自己的路径映射规则。
开发一个应用,首先我们设计编辑html模板页面,随后编写erl页面代码,最后是编译部署,启动。
创建一个Web版的"Hello World":
$ mkdir myfirstweb
$ cd myfirstweb
$ nitrogen create helloworld
Copy Nitrogen Static: "livevalidation.js"
...
Creating file: "helloworld_app.erl"
$ ls
doc ebin Emakefile Makefile src start.sh wwwroot
$ cd src/pages/
$ ls
web_index.erl
接下来让我们编辑web_index.erl::
-module (web_index).
-include_lib ("nitrogen/include/wf.inc").
-compile(export_all).
main() ->
#template { file="./wwwroot/template.html"}.
title() ->
"hello world".
body() ->
[
#h1{text ="My First Nirogen Web"},
#panel{text = "Hello World"}
].
event(_) -> ok.
保存后,继续:
$ cd ../..
$ ./start.sh
Starting Nitrogen.
Erlang (BEAM) emulator version 5.6.5 [source] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.6.5 (abort with ^G)
(nitrogen@localhost)1> Recompile: ./src/pages/web_index
---
Nitrogen is now running on inets.
Serving files from: ./wwwroot.
Open your browser to: http://localhost:8000
---
启动浏览器,URL:http://localhost:8000/
看到Hello World了吧。
相关推荐
A Versatile, Ultralight, Nitrogen‐Doped Graphene Framework.pdf
Nitrogen leaching in response to increased nitrogen inputs in subtropical monsoon forests in southern China
erlang的Web开发 随着Erlang和FP的普及,总有人想把Erlang用在Web开发上。 虽然这不一定是个靠谱的想法,但是,...Nitrogen 就是其中一个实现。它主要关注在快速开发交互密集型的Web,喜欢Erlang的童鞋可以看一下。
Nitrogen6X_Hardware_Manual_rev1.3 硬件手册,第1.3版。
最优水分条件下冬小麦根系吸水、吸氮与根氮含量之间的关系,石建初,左强,在土壤-植物系统中,根系吸收土壤中的水、氮对植物生长以及对土壤中的水、氮运移都具有非常重要的作用。在考虑植物根长的基础之
Introduction to Nitrogen
nitrogen-1.1-wm5.cab WINCE PPC
NITROGEN6X_circuit drawing REV4详细硬件原理图,第4版
Amelioration of nitrogen difference method in legume intercropping,余常兵,李隆,Nitrogen difference method is commonly used to appraise biological nitrogen fixation, which is a well established ...
基于超导谐振腔和NV色心系综混合体系的纠缠复制,马胜利,李蓬勃,研究了一个由超导传输线腔链和NV色心系综组成的混合量子体系。如果位于两个强链的第一对腔被一双模微波压缩场驱动,则在稳态时通过
用于Erlang的Nitrogen Web框架 Nitrogen是基于Erlang的Web框架,它使您可以使用纯Erlang技术堆栈来开发无限可扩展的,富Ajax的Web应用程序。 有关更多信息,请参见。 入门 遵循位于的教程 在Linux和OSX上构建氮气 ...
Microstructure thermostability of high nitrogen austenitic stainless steel,袁志钟,戴起勋,High nitrogen austenitic stainless steel, Fe24Mn18Cr3Ni0.62N, was isothermal annealed from 750℃ to 900 ℃ ...
使用nitrogen做的一个内部沟通聊天室,方便群发文件和图片,当然包换最基本的文本信息聊天了。
注册表注册表服务为 Nitrogen 中的安全主体(设备、应用程序和用户)提供身份和发现服务。安装git clone https://github.com/nitrogenjs/registry cd frontdoor npm install node server.js如何贡献反馈:我们很乐意...
铁膜磁性氮调制,W. H. Zhong,B. K. Tay,The structure and magnetic properties can be modulated by adding nitrogen because of the aleration of Fe atomic valence upon reaction.
CVN impact properties of high-nitrogen austenitic stainless steels,袁志钟,戴起勋,The Charpy v notch (CVN) impact properties of two kinds of high-nitrogen austenitic stainless steels (HNASS) Fe24Mn...
Nitrogen fixation of faba bean interacting with a non-legume in two contrasting intercropping systems,范分良,余常兵,A field experiment was carried out to quantify biological nitrogen fixation (BNF)...
Nitrogen ratio and RTA optimization on sputtered TiN/SiO2/Si electrolyte-insulatoresemiconductor structure for pH sensing characteristics
资源分类:Python库 所属语言:Python 资源全名:nitrogen-aggr-0.8.86.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
玉米-大豆间作和施氮对红壤旱地作物碳氮吸收的影响,杨文亭,缪建群,本文主要通过盆栽试验研究红壤旱地种植模式(玉米单作、大豆单作和玉米-大豆间作)和施氮(0, 75, 150, 225, 300 kg/ha)对作物生物量和碳氮吸�