21 lines
484 B
Plaintext
21 lines
484 B
Plaintext
# Route with custom number of iterations
|
|
cached get ~/:n {
|
|
|
|
# Get the Number of Iterations from the URL Params
|
|
int n = req.params.n || 100
|
|
|
|
# Loop through each iteration
|
|
for (i in range(n)) {
|
|
|
|
if (i % 2 == 0 && i % 3 == 0) { res.write("FizzBuzz\n") continue }
|
|
if (i % 2 == 0) { res.write("Fizz\n"); continue; }
|
|
if (i % 3 == 0) { res.write("Buzz\n"); continue; }
|
|
res.write(i + "\n");
|
|
|
|
}
|
|
|
|
# Close the connection
|
|
res.end();
|
|
|
|
}
|