router.get("greets", String.parameter)
{ (req)-> String in
let name = try req.parameters.next(String.self)
return "Hello, \(name)!"
}This path will respond to requests for /greets/Broseph by printing out "Hello, Broseph!"
router.get("greets", String.parameter)
{ (req)-> String in
let name = try req.parameters.next(String.self)
return "Hello, \(name)!"
}This path will respond to requests for /greets/Broseph by printing out "Hello, Broseph!"
router.get("page", Int.parameter, String.parameter)
{ (req)-> String in
let num = try req.parameters.next(Int.self)
let section = try req.parameters.next(String.self)
return "Loading page \(num), section \(section)."
}| #!/usr/bin/env python3 | |
| """ | |
| Very simple HTTP server in python. | |
| Usage:: | |
| ./dummy-web-server.py [<port>] | |
| Send a GET request:: | |
| curl http://localhost |
import argparse
import json
arg = argparse.ArgumentParser()
arg.add_argument("-c", "--conf", required=True, help="path to the JSON configuration file")
args = vars(arg.parse_args())
conf = json.load(open(args["conf"]))func add(x: Int, y: Int, z: Int) -> Int {
return x + y + z
}
let sum = add(x: 1, y: 2, z: 3)
print(sum)
//-> 6
func addX(_ x: Int) -> (Int, Int)-> Int {func countDown(from: Int) {
// Stop condition
if from < 0 {
return
}
print(from)
// Recursion
countDown(from: from - 1)First the modules. From your virtual environment:
$ mkvirtualenv coreml -p python3
$ workon coreml
(coreml)$ pip install -U pandas
(coreml)$ pip install -U sklearn
(coreml)$ pip install -U scipy
(coreml)$ pip install -U coremltools