This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:16.04 | |
# Install dependencies | |
RUN apt-get update | |
RUN apt-get -y install apache2 | |
# Install apache and write hello world message | |
RUN echo 'Hello World!' > /var/www/html/index.html | |
# Configure apache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = async function (context, req) { | |
if (req.body.email) { | |
var email = { | |
from: { | |
email: req.body.email | |
}, | |
subject: "Contact form submission from: " + req.body.name, | |
content: [{ | |
type: 'text/plain', | |
value: req.body.message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"disabled": false, | |
"bindings": [ | |
{ | |
"authLevel": "anonymous", | |
"type": "httpTrigger", | |
"direction": "in", | |
"name": "req", | |
"methods": [ | |
"get", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = async function (context, req) { | |
context.log('JavaScript HTTP trigger function processed a request.'); | |
if (req.query.name || (req.body && req.body.name)) { | |
context.res = { | |
// status: 200, /* Defaults to 200 */ | |
body: "Hello " + (req.query.name || req.body.name) | |
}; | |
} | |
else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Hello World</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" | |
crossorigin="anonymous"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function submitMessage(e) { | |
e.preventDefault(); | |
let name = document.getElementById('name').value; | |
fetch('<YOUR FUNCTION URL GOES HERE>', { | |
method: 'POST', | |
headers: { | |
'Accept': 'application/json, text/plain, */*', | |
'Content-type': 'application/json' | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function processResponse(response) { | |
if (response.status === 200) { | |
output = | |
` | |
<div class="alert alert-success" role="alert"> | |
Hello, ${document.getElementById('name').value}! It's nice to meet you! | |
</div> | |
`; | |
document.getElementById('output').innerHTML = output; | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:alpine | |
WORKDIR /usr/app | |
COPY package*.json ./ | |
RUN npm install | |
COPY . . | |
CMD ["npm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const config = require('./config'); | |
const express = require('express'); | |
const app = express(); | |
app.get('/', (req, res) => { | |
res.send('Hello World v2!'); | |
}); | |
app.listen(config.port, () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
yum update -y | |
yum install -y httpd | |
echo '<h1>Hello World</h1>' > /var/www/html/index.html | |
systemctl start httpd | |
systemctl enable httpd |