about summary refs log tree commit diff stats
path: root/src/io/about.nim
blob: a3ecb1fe910bb33c006b8c30161f1aac5ac8df75 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import streams
import tables

import io/request
import ips/serialize
import types/url

const chawan = staticRead"res/chawan.html"
const Headers = {
  "Content-Type": "text/html"
}.toTable()

proc loadAbout*(request: Request, ostream: Stream) =
  if request.url.pathname == "blank":
    ostream.swrite(0)
    ostream.swrite(200) # ok
    let headers = newHeaderList(Headers)
    ostream.swrite(headers)
  elif request.url.pathname == "chawan":
    ostream.swrite(0)
    ostream.swrite(200) # ok
    let headers = newHeaderList(Headers)
    ostream.swrite(headers)
    ostream.write(chawan)
  else:
    ostream.swrite(-1)
  ostream.flush()