4 category: JavaScript libraries
8 [Camp](https://github.com/espadrine/sc/) is a Node.js web server framework. This guide targets Camp v17.x.
22 const Camp = require('camp')
23 const camp = Camp.start({ port: 1234 })
31 <body>Hello world!</body>
34 Camp serves files in `web/` by default.
38 #### Handles `/search?q=rainbows`
41 camp.path('/search', (req, res) => {
43 res.json({ results: ··· })
48 Also available: `camp.post`, `camp.get`.
53 const tpl = Camp.template('./templates/post.html')
55 camp.path('/blog/:post.html', (req, res) => {
63 See: [Templates](https://github.com/espadrine/sc/blob/master/doc/Readme.md#templates)
68 camp.notFound('/*.lol', (req, res) => {
74 See: [Fall through](https://github.com/espadrine/sc/blob/master/doc/Readme.md#fall-through)
79 camp.handle((req, res, next) => {
80 res.setHeader('X-Hello', 'world')
86 See: [Handlers](https://github.com/espadrine/sc/blob/master/doc/Readme.md#handlers)
94 const tpl = Camp.template('/templates/post.html')
96 camp.path('/blog/:post.html', (req, res) => {
102 {: data-line="1,4,5,6"}
104 ### Implicit templates
107 camp.path('blog.html')
110 Uses `blog.html` as a template.
112 See: [Templates](https://github.com/espadrine/sc/blob/master/doc/Readme.md#templates)
120 camp.ws('/path', (socket) => { ··· })
124 camp.wsChannels[path]
128 camp.wsBroadcast('/path', (req, res) => {
132 Sorry I don't completely understand this yet, but check it out in their docs.
134 See: [WebSocket](https://github.com/espadrine/sc/blob/master/doc/Readme.md#websocket)