Skip to content

Instantly share code, notes, and snippets.

@atifazad
Last active February 15, 2020 18:26
Show Gist options
  • Save atifazad/95d6a496118be8e9a2f9f3047f47127a to your computer and use it in GitHub Desktop.
Save atifazad/95d6a496118be8e9a2f9f3047f47127a to your computer and use it in GitHub Desktop.
Hello World! in various languages and frameworks (embedded in https://atifazad.com/tutorials/general/hello-world/)
This gist contains Hello World examples for several programming languages and framworks. This codes from this gist are being used (as embed code) at Hello World page at my weebsite (https://atifazad.com/tutorials/general/hello-world/)
void main() {
print("Hello World!");
}
// write to console
console.log("Hello World!");
// show a browser alert with text hello world
alert("Hello World!");
<?php echo "Hello World!"; ?>
print("Hello World!")
puts "Hello World!"
#!/bin/sh
echo "Hello World!"
// Execute in Xcode playground
print("Hello World!")
/**
* Assuming you've already installed Nodejs and Express JS
* If not, please follow: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/development_environment
*
*/
var express = require('express');
var app = express();
const hostname = "127.0.0.1";
const port = 3000;
app.get('/', function(req, res) {
res.send("Hello World!");
});
app.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
/**
* Save above code in a file 'app.js' and execute following command in console
* while you're in your app directory.
*/
> node app.js
/**
* You should see "Server running at http://127.0.0.1:3000" in console and...
* Hit 127.0.0.1:3000 in your browser, you should see Hello World! in browser.
*/
/**
* Assuming you've already installed Nodejs
*/
// Load HTTP module
const http = require("http");
const hostname = "127.0.0.1";
const port = 3000;
// Create HTTP server
const server = http.createServer((req, res) => {
// Set the response HTTP header with HTTP status and Content type
res.writeHead(200, {'Content-Type': 'text/plain'});
// Send the response body "Hello World!"
res.end("Hello World!n");
});
// Prints a log once the server starts listening
server.listen(port, hostname, () => {
console.log("Server running at http://${hostname}:${port}/");
})
/**
* Save above code in a file 'app.js' and execute following command in console
* while you're in your app directory.
*/
> node app.js
/**
* You should see "Server running at http://127.0.0.1:3000" in console and...
* Hit 127.0.0.1:3000 in your browser, you should see Hello World! in browser.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment