Markdown code blocks migration part 7 (#20547)
This commit is contained in:
parent
13b3ea71da
commit
19ff746916
17 changed files with 426 additions and 411 deletions
|
|
@ -9,25 +9,25 @@
|
|||
|
||||
## This module implements helper procs for CGI applications. Example:
|
||||
##
|
||||
## .. code-block:: Nim
|
||||
## ```Nim
|
||||
## import std/[strtabs, cgi]
|
||||
##
|
||||
## import std/[strtabs, cgi]
|
||||
##
|
||||
## # Fill the values when debugging:
|
||||
## when debug:
|
||||
## setTestData("name", "Klaus", "password", "123456")
|
||||
## # read the data into `myData`
|
||||
## var myData = readData()
|
||||
## # check that the data's variable names are "name" or "password"
|
||||
## validateData(myData, "name", "password")
|
||||
## # start generating content:
|
||||
## writeContentType()
|
||||
## # generate content:
|
||||
## write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
|
||||
## write(stdout, "<html><head><title>Test</title></head><body>\n")
|
||||
## writeLine(stdout, "your name: " & myData["name"])
|
||||
## writeLine(stdout, "your password: " & myData["password"])
|
||||
## writeLine(stdout, "</body></html>")
|
||||
## # Fill the values when debugging:
|
||||
## when debug:
|
||||
## setTestData("name", "Klaus", "password", "123456")
|
||||
## # read the data into `myData`
|
||||
## var myData = readData()
|
||||
## # check that the data's variable names are "name" or "password"
|
||||
## validateData(myData, "name", "password")
|
||||
## # start generating content:
|
||||
## writeContentType()
|
||||
## # generate content:
|
||||
## write(stdout, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n")
|
||||
## write(stdout, "<html><head><title>Test</title></head><body>\n")
|
||||
## writeLine(stdout, "your name: " & myData["name"])
|
||||
## writeLine(stdout, "your password: " & myData["password"])
|
||||
## writeLine(stdout, "</body></html>")
|
||||
## ```
|
||||
|
||||
import strutils, os, strtabs, cookies, uri
|
||||
export uri.encodeUrl, uri.decodeUrl
|
||||
|
|
@ -252,9 +252,9 @@ proc setTestData*(keysvalues: varargs[string]) =
|
|||
## Fills the appropriate environment variables to test your CGI application.
|
||||
## This can only simulate the 'GET' request method. `keysvalues` should
|
||||
## provide embedded (name, value)-pairs. Example:
|
||||
##
|
||||
## .. code-block:: Nim
|
||||
## setTestData("name", "Hanz", "password", "12345")
|
||||
## ```Nim
|
||||
## setTestData("name", "Hanz", "password", "12345")
|
||||
## ```
|
||||
putEnv("REQUEST_METHOD", "GET")
|
||||
var i = 0
|
||||
var query = ""
|
||||
|
|
@ -269,9 +269,9 @@ proc setTestData*(keysvalues: varargs[string]) =
|
|||
proc writeContentType*() =
|
||||
## Calls this before starting to send your HTML data to `stdout`. This
|
||||
## implements this part of the CGI protocol:
|
||||
##
|
||||
## .. code-block:: Nim
|
||||
## write(stdout, "Content-type: text/html\n\n")
|
||||
## ```Nim
|
||||
## write(stdout, "Content-type: text/html\n\n")
|
||||
## ```
|
||||
write(stdout, "Content-type: text/html\n\n")
|
||||
|
||||
proc resetForStacktrace() =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue