Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions serving/samples/helloworld-csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ recreate the source files from this folder.
```csharp
app.Run(async (context) =>
{
var target = Environment.GetEnvironmentVariable("TARGET") ?? "NOT SPECIFIED";
await context.Response.WriteAsync($"Hello World: {target}\n");
var target = Environment.GetEnvironmentVariable("TARGET") ?? "World";
await context.Response.WriteAsync($"Hello {target}\n");
});
```

Expand Down
4 changes: 2 additions & 2 deletions serving/samples/helloworld-csharp/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)

app.Run(async (context) =>
{
var target = Environment.GetEnvironmentVariable("TARGET") ?? "NOT SPECIFIED";
await context.Response.WriteAsync($"Hello World: {target}\n");
var target = Environment.GetEnvironmentVariable("TARGET") ?? "World";
await context.Response.WriteAsync($"Hello {target}\n");
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions serving/samples/helloworld-go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ following instructions recreate the source files from this folder.
log.Print("Hello world received a request.")
target := os.Getenv("TARGET")
if target == "" {
target = "NOT SPECIFIED"
target = "World"
}
fmt.Fprintf(w, "Hello World: %s!\n", target)
fmt.Fprintf(w, "Hello %s!\n", target)
}

func main() {
Expand Down
4 changes: 2 additions & 2 deletions serving/samples/helloworld-go/helloworld.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
log.Print("Hello world received a request.")
target := os.Getenv("TARGET")
if target == "" {
target = "NOT SPECIFIED"
target = "World"
}
fmt.Fprintf(w, "Hello World: %s!\n", target)
fmt.Fprintf(w, "Hello %s!\n", target)
}

func main() {
Expand Down
4 changes: 2 additions & 2 deletions serving/samples/helloworld-haskell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ following instructions recreate the source files from this folder.

main :: IO ()
main = do
t <- fromMaybe "NOT SPECIFIED" <$> lookupEnv "TARGET"
t <- fromMaybe "World" <$> lookupEnv "TARGET"
scotty 8080 (route t)

route :: String -> ScottyM()
route t = get "/" $ hello t

hello :: String -> ActionM()
hello t = text $ pack ("Hello world: " ++ t)
hello t = text $ pack ("Hello " ++ t)
```

1. In your project directory, create a file named `Dockerfile` and copy the code
Expand Down
4 changes: 2 additions & 2 deletions serving/samples/helloworld-haskell/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import Web.Scotty.Trans

main :: IO ()
main = do
t <- fromMaybe "NOT SPECIFIED" <$> lookupEnv "TARGET"
t <- fromMaybe "World" <$> lookupEnv "TARGET"
scotty 8080 (route t)

route :: String -> ScottyM()
route t = get "/" $ hello t

hello :: String -> ActionM()
hello t = text $ pack ("Hello world: " ++ t)
hello t = text $ pack ("Hello " ++ t)
4 changes: 2 additions & 2 deletions serving/samples/helloworld-java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ recreate the source files from this folder.
@SpringBootApplication
public class HelloworldApplication {

@Value("${TARGET:NOT SPECIFIED}")
@Value("${TARGET:World}")
String target;

@RestController
class HelloworldController {
@GetMapping("/")
String hello() {
return "Hello World: " + target;
return "Hello " + target;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
@SpringBootApplication
public class HelloworldApplication {

@Value("${TARGET:NOT SPECIFIED}")
@Value("${TARGET:World}")
String message;

@RestController
class HelloworldController {
@GetMapping("/")
String hello() {
return "Hello World: " + message;
return "Hello " + message;
}
}

Expand Down
2 changes: 0 additions & 2 deletions serving/samples/helloworld-nodejs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ WORKDIR /usr/src/app
COPY package*.json ./

RUN npm install --only=production
# If you are building your code for production
# RUN npm install --only=production

# Bundle app source
COPY . .
Expand Down
11 changes: 4 additions & 7 deletions serving/samples/helloworld-nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ recreate the source files from this folder.
app.get('/', function (req, res) {
console.log('Hello world received a request.');

var target = process.env.TARGET || 'NOT SPECIFIED';
res.send('Hello world: ' + target);
var target = process.env.TARGET || 'World';
res.send('Hello ' + target);
});

var port = 8080;
Expand All @@ -71,8 +71,7 @@ recreate the source files from this folder.
"description": "",
"main": "app.js",
"scripts": {
"start": "node app.js",
"test": "echo \"Error: no test specified\" && exit 1"
"start": "node app.js"
},
"author": "",
"license": "Apache-2.0"
Expand All @@ -94,9 +93,7 @@ recreate the source files from this folder.
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm install --only=production
RUN npm install --only=production

# Bundle app source
COPY . .
Expand Down
4 changes: 2 additions & 2 deletions serving/samples/helloworld-nodejs/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const app = express();
app.get('/', function (req, res) {
console.log('Hello world received a request.');

var target = process.env.TARGET || 'NOT SPECIFIED';
res.send('Hello world: ' + target);
var target = process.env.TARGET || 'World';
res.send('Hello ' + target);
});

var port = 8080;
Expand Down
5 changes: 2 additions & 3 deletions serving/samples/helloworld-nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
"description": "Simple hello world sample in Node",
"main": "app.js",
"scripts": {
"start": "node app.js",
"test": "echo \"Error: no test specified\" && exit 1"
"start": "node app.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/knative/serving.git"
"url": "git+https://github.com/knative/docs.git"
},
"author": "",
"license": "Apache-2.0",
Expand Down
4 changes: 2 additions & 2 deletions serving/samples/helloworld-php/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ following instructions recreate the source files from this folder.

```php
<?php
$target = getenv('TARGET', true) ?: "NOT SPECIFIED";
echo sprintf("Hello World: %s!\n", $target);
$target = getenv('TARGET', true) ?: "World";
echo sprintf("Hello %s!\n", $target);
?>
```

Expand Down
4 changes: 2 additions & 2 deletions serving/samples/helloworld-php/index.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
$target = getenv('TARGET', true) ?: "NOT SPECIFIED";
echo sprintf("Hello World: %s!\n", $target);
$target = getenv('TARGET', true) ?: "World";
echo sprintf("Hello %s!\n", $target);
?>
4 changes: 2 additions & 2 deletions serving/samples/helloworld-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ The following instructions recreate the source files from this folder.

@app.route('/')
def hello_world():
target = os.environ.get('TARGET', 'NOT SPECIFIED')
return 'Hello World: {}!\n'.format(target)
target = os.environ.get('TARGET', 'World')
return 'Hello {}!\n'.format(target)

if __name__ == "__main__":
app.run(debug=True,host='0.0.0.0',port=int(os.environ.get('PORT', 8080)))
Expand Down
4 changes: 2 additions & 2 deletions serving/samples/helloworld-python/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

@app.route('/')
def hello_world():
target = os.environ.get('TARGET', 'NOT SPECIFIED')
return 'Hello World: {}!\n'.format(target)
target = os.environ.get('TARGET', 'World')
return 'Hello {}!\n'.format(target)

if __name__ == "__main__":
app.run(debug=True,host='0.0.0.0',port=int(os.environ.get('PORT', 8080)))
4 changes: 2 additions & 2 deletions serving/samples/helloworld-ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ The following instructions recreate the source files from this folder.
set :bind, '0.0.0.0'

get '/' do
target = ENV['TARGET'] || 'NOT SPECIFIED'
"Hello World: #{target}!\n"
target = ENV['TARGET'] || 'World'
"Hello #{target}!\n"
end
```

Expand Down
4 changes: 2 additions & 2 deletions serving/samples/helloworld-ruby/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
set :bind, '0.0.0.0'

get '/' do
target = ENV['TARGET'] || 'NOT SPECIFIED'
"Hello World: #{target}!\n"
target = ENV['TARGET'] || 'World'
"Hello #{target}!\n"
end
4 changes: 2 additions & 2 deletions serving/samples/helloworld-rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ following instructions recreate the source files from this folder.
let new_service = || {
service_fn_ok(|_| {

let mut hello = "Hello world: ".to_string();
let mut hello = "Hello ".to_string();
match env::var("TARGET") {
Ok(target) => {hello.push_str(&target);},
Err(_e) => {hello.push_str("NOT SPECIFIED")},
Err(_e) => {hello.push_str("World")},
};

Response::new(Body::from(hello))
Expand Down
4 changes: 2 additions & 2 deletions serving/samples/helloworld-rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ fn main() {
let new_service = || {
service_fn_ok(|_| {

let mut hello = "Hello world: ".to_string();
let mut hello = "Hello ".to_string();
match env::var("TARGET") {
Ok(target) => {hello.push_str(&target);},
Err(_e) => {hello.push_str("NOT SPECIFIED")},
Err(_e) => {hello.push_str("World")},
};

Response::new(Body::from(hello))
Expand Down