Skip to content

Instantly share code, notes, and snippets.

@buddies2705
Created January 25, 2019 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buddies2705/c7ccbf5104c8441df9d23c5ff9d86706 to your computer and use it in GitHub Desktop.
Save buddies2705/c7ccbf5104c8441df9d23c5ff9d86706 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<body>
<script src="https://unpkg.com/mithril/mithril.js"></script>
<script>
var root = document.body
var count = 0
var increment = function() {
m.request({
method: "PUT",
url: "//rem-rest-api.herokuapp.com/api/tutorial/1",
data: {count: count + 1},
withCredentials: true,
})
.then(function(data) {
count = parseInt(data.count)
})
}
var Hello = {
view: function() {
return m("main", [
m("h1", {class: "title"}, "My first app"),
m("button", {onclick: increment}, count + " clicks"),
])
}
}
var Home = {
view: function() {
return m("a", {
href: "#!/hello"
}, "Enter!")
}
}
m.route(root, "/home", {
"/home": Home,
"/hello": Hello,
})
// your code goes here!
</script>
</body>
</html>
var express = require('express');
var app = express();
app.get('/', function(req, res) {
res.sendFile('/home/batman/Pictures/mithril/src/index.html');
});
app.listen(3001);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment