A janet web framework

栏目: IT技术 · 发布时间: 4年前

内容简介:Joy is a full stack web framework written inFirst make sureNext, install the joy cli like this

You Found Joy!

Joy is a full stack web framework written in janet

(use joy)

(defn home [request]
  (render :text "You found joy!"))

(defroutes routes
  [:get "/" home])

(def app (handler routes))

(server app 8000)

Getting Started

First make sure janet is installed

Next, install the joy cli like this

jpm install joy

Hopefully the joy executable will be on your path and ready to roll. Now, run the following from your terminal

joy new my-joy-project

This should create a new directory called my-joy-project and it should create a few files and things to get you started. Next, let's create a database, a table and connect it with routes and a few functions for handling requests.

Create a new sqlite database

If you aren't already in the my-joy-project directory, go ahead and get in there. Now run

joy create db

This creates a new empty database named dev.sqlite3 . Let's fill it up.

Taking it for a spin

Alright now that we have a project and a sqlite database set up, it's time to test it out in the browser:

joy server

This should start an http server that's listening at http://localhost:8000 .

Create a database table

Run this to create a new migration with a table with a few columns:

joy create table account 'email text not null unique' 'password text not null'

This has created one file in your db/migrations folder that is waiting to get applied to the database.

Run database migrations

Run this from your terminal

joy migrate

This will output what just happened to your database and create a new file db/schema.sql .

Create a route file

In joy there are no ORMs, no classes, and no objects, just functions that take in requests and return responses.

Let's make a route file that corresponds to the table from earlier

joy create route account

Those commands have created another new file: src/routes/account.janet and updated your src/routes.janet file with a few helpful routes.

Go ahead and check out the new account routes in the browser now: http://localhost:8000/account

Joy can do a lot more than that, check out the docs here

Why?

I wanted something that felt like coast but took so little resources (memory + cpu) I could run dozens (if not hundreds) of websites on a cheap VPS .


以上所述就是小编给大家介绍的《A janet web framework》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Python算法教程

Python算法教程

[挪威] Magnus Lie Hetland 赫特兰 / 凌杰、陆禹淳、顾俊 / 人民邮电出版社 / 2016-1-1 / 69.00元

本书用Python语言来讲解算法的分析和设计。本书主要关注经典的算法,但同时会为读者理解基本算法问题和解决问题打下很好的基础。全书共11章。分别介绍了树、图、计数问题、归纳递归、遍历、分解合并、贪心算法、复杂依赖、Dijkstra算法、匹配切割问题以及困难问题及其稀释等内容。本书在每一章结束的时候均有练习题和参考资料,这为读者的自我检查以及进一步学习提供了较多的便利。在全书的最后,给出了练习题的提......一起来看看 《Python算法教程》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

URL 编码/解码
URL 编码/解码

URL 编码/解码