add web widget example
This commit is contained in:
parent
1adcd2eada
commit
b73d8a010c
18
README.md
18
README.md
|
@ -1,8 +1,22 @@
|
|||
# viewcounter
|
||||
ethical view counting api
|
||||
|
||||
## usage
|
||||
### requesting view counts
|
||||
## examples
|
||||
### embedded view counter
|
||||
```html
|
||||
<div id="view-count"></div>
|
||||
<script>
|
||||
var req = new XMLHttpRequest();
|
||||
req.addEventListener("load", function () {
|
||||
document.getElementById("view-count")
|
||||
.innerHTML = "<b>page views</b> " + JSON.parse(this.responseText).views;
|
||||
});
|
||||
req.open("POST", "/viewcounter");
|
||||
req.send("/index.html");
|
||||
</script>
|
||||
```
|
||||
|
||||
### requesting all view counts
|
||||
sending a GET request will return a json object with all the stored viewcounts
|
||||
```sh
|
||||
$ curl localhost:8001/viewcounter
|
||||
|
|
Loading…
Reference in New Issue