mirror of
https://api.glitch.com/git/presence-button
synced 2024-11-05 06:47:29 +00:00
🏏🍱 Checkpoint
./package.json:933874/347 ./server.js:933874/577 ./views/index.html:933874/979
This commit is contained in:
parent
30930b4ced
commit
752427dec7
10
package.json
10
package.json
@ -1,10 +1,7 @@
|
||||
{
|
||||
"//1": "describes your app and its dependencies",
|
||||
"//2": "https://docs.npmjs.com/files/package.json",
|
||||
"//3": "updating this file will download and update your packages",
|
||||
"name": "hello-express",
|
||||
"name": "presence-button",
|
||||
"version": "0.0.1",
|
||||
"description": "A simple Node app built on Express, instantly up and running.",
|
||||
"description": "Always-up server for Fuz presence button",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"start": "node server.js"
|
||||
@ -16,12 +13,11 @@
|
||||
"node": "8.x"
|
||||
},
|
||||
"repository": {
|
||||
"url": "https://glitch.com/edit/#!/hello-express"
|
||||
"url": "https://glitch.com/edit/#!/presence-button"
|
||||
},
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"node",
|
||||
"glitch",
|
||||
"express"
|
||||
]
|
||||
}
|
||||
|
@ -1,42 +0,0 @@
|
||||
// client-side js
|
||||
// run by the browser each time your view template is loaded
|
||||
|
||||
console.log("hello world :o");
|
||||
|
||||
// our default array of dreams
|
||||
const dreams = [
|
||||
"Find and count some sheep",
|
||||
"Climb a really tall mountain",
|
||||
"Wash the dishes"
|
||||
];
|
||||
|
||||
// define variables that reference elements on our page
|
||||
const dreamsList = document.getElementById("dreams");
|
||||
const dreamsForm = document.forms[0];
|
||||
const dreamInput = dreamsForm.elements["dream"];
|
||||
|
||||
// a helper function that creates a list item for a given dream
|
||||
const appendNewDream = function(dream) {
|
||||
const newListItem = document.createElement("li");
|
||||
newListItem.innerHTML = dream;
|
||||
dreamsList.appendChild(newListItem);
|
||||
};
|
||||
|
||||
// iterate through every dream and add it to our page
|
||||
dreams.forEach(function(dream) {
|
||||
appendNewDream(dream);
|
||||
});
|
||||
|
||||
// listen for the form to be submitted and add a new dream when it is
|
||||
dreamsForm.onsubmit = function(event) {
|
||||
// stop our form submission from refreshing the page
|
||||
event.preventDefault();
|
||||
|
||||
// get dream value and add it to the list
|
||||
dreams.push(dreamInput.value);
|
||||
appendNewDream(dreamInput.value);
|
||||
|
||||
// reset form
|
||||
dreamInput.value = "";
|
||||
dreamInput.focus();
|
||||
};
|
18
server.js
18
server.js
@ -1,13 +1,6 @@
|
||||
// server.js
|
||||
// where your node app starts
|
||||
|
||||
// init project
|
||||
const express = require("express");
|
||||
const app = express();
|
||||
|
||||
// we've started you off with Express,
|
||||
// but feel free to use whatever libs or frameworks you'd like through `package.json`.
|
||||
|
||||
// http://expressjs.com/en/starter/static-files.html
|
||||
app.use(express.static("public"));
|
||||
|
||||
@ -16,7 +9,16 @@ app.get("/", function(request, response) {
|
||||
response.sendFile(__dirname + "/views/index.html");
|
||||
});
|
||||
|
||||
// listen for requests :)
|
||||
// http://expressjs.com/en/starter/basic-routing.html
|
||||
app.get("/img", function(request, response) {
|
||||
response.sendFile(__dirname + "/views/index.html");
|
||||
});
|
||||
|
||||
const listener = app.listen(process.env.PORT, function() {
|
||||
console.log("Your app is listening on port " + listener.address().port);
|
||||
});
|
||||
|
||||
process.on("SIGTERM", function () {
|
||||
console.log("SIGTERM received, sending SOS to Resurrect...");
|
||||
require('https').get("https://resurrect.glitch.me/"+process.env.PROJECT_DOMAIN+"", process.exit)
|
||||
});
|
@ -10,38 +10,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Welcome to Glitch!</title>
|
||||
<meta name="description" content="A cool thing made with Glitch">
|
||||
<link id="favicon" rel="icon" href="https://glitch.com/edit/favicon-app.ico" type="image/x-icon">
|
||||
<title>Fuz presence button</title>
|
||||
<meta name="description" content="Public API for Fuz hackerspace presence button">
|
||||
<link id="favicon" rel="icon" href="https://fuz.frama.site/medias/5c02ae843c25e.jpg" type="image/x-icon">
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<!-- import the webpage's stylesheet -->
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
|
||||
<!-- import the webpage's client-side javascript file -->
|
||||
<script src="/client.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>
|
||||
A Dream of the Future
|
||||
Fuz presence button public API
|
||||
</h1>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<p class="bold">Oh hi,</p>
|
||||
|
||||
<p>Tell me your hopes and dreams:</p>
|
||||
|
||||
<form>
|
||||
<input name="dream" type="text" maxlength="100" placeholder="Dreams!" aria-labelledby="submit-dream">
|
||||
<button type="submit" id="submit-dream">Submit Dream</button>
|
||||
</form>
|
||||
<p>See documentation for this project on <a href="https://wiki.fuz.re/doku.php?id=projets:fuz:presence_button">Fuz wiki</a>:</p>
|
||||
|
||||
<section class="dreams">
|
||||
<ul id="dreams"></ul>
|
||||
<ul id="dreams">
|
||||
<li><a href="/img">image API</a></li>
|
||||
<li><a href="/api">ajax API</a></li>
|
||||
</ul>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user