diff --git a/README.md b/README.md new file mode 100644 index 0000000..59eb81e --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# API Workshop Material diff --git a/app.css b/app.css new file mode 100644 index 0000000..10ccb76 --- /dev/null +++ b/app.css @@ -0,0 +1,18 @@ +body { + background: white; + color: #323232; + font-weight: 300; + font-family: Helevtica neue, robot; +} + +.button { + background-color: #4caf50; /* Green */ + border: none; + color: white; + padding: 15px 32px; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 16px; + cursor: pointer; +} diff --git a/app.js b/app.js new file mode 100644 index 0000000..3a8ce06 --- /dev/null +++ b/app.js @@ -0,0 +1,57 @@ +fetch ('https://api.github.com/users/dhvani35729') + .then (response => response.json ()) + .then (data => { + console.log (data); + var greetingNode = document.getElementById ('greeting'); + greetingNode.innerHTML += ' ' + data.login + '!'; + var bioNode = document.getElementById ('userBio'); + bioNode.innerHTML = data.bio; + var userImageNode = document.getElementById ('userImg'); + userImageNode.src = data.avatar_url; + userImageNode.width = 200; + }); + +function loadUsers () { + console.log ('Loading users..'); + fetch ('https://reqres.in/api/users') + .then (res => res.json ()) + .then (data => { + console.log (data); + var userTable = document.getElementById ('userTable'); + + data.data.forEach (user => { + console.log (user.email); + var newRow = userTable.insertRow (); + var colId = document.createElement ('th'); + var colName = document.createElement ('th'); + var colEmail = document.createElement ('th'); + let textId = document.createTextNode (user.id); + let textName = document.createTextNode (user.first_name); + let textEmail = document.createTextNode (user.email); + colId.appendChild (textId); + colName.appendChild (textName); + colEmail.appendChild (textEmail); + newRow.appendChild (colId); + newRow.appendChild (colName); + newRow.appendChild (colEmail); + }); + }); +} + +function sendSwit () { + console.log ('Sending message to Swit'); + var inputText = document.getElementById ('message').value; + fetch ('https://hook.swit.io/chat/200326205355708CTEB/ntq1pBDDQqf3ne3NgZFL', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify ({ + text: inputText, + }), + }) + .then (res => res.json ()) + .then (data => console.log (data)); + + return false; +} diff --git a/bot.py b/bot.py new file mode 100644 index 0000000..71cf5ae --- /dev/null +++ b/bot.py @@ -0,0 +1,18 @@ +# importing the requests library +import requests +import json +from threading import Timer + + +def askData(): + Timer(1.0, askData).start() + + API_ENDPOINT = "https://hook.swit.io/chat/200328231505006C9sA/FihS4PXQOpHrBcc5lWm7" + + data = {'text':"I want data"} + + r = requests.post(url = API_ENDPOINT, json=data) + + print(r) + +askData() \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..9c7154c --- /dev/null +++ b/index.html @@ -0,0 +1,45 @@ + + + + + + + + + +

+ Hey there, +

+

+

+ + +
+ Load Users + + + + + + + + + + + + +
idnameemal
+ +
+
+
+
+ +
+ + + + + + + \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..9731b46 --- /dev/null +++ b/index.js @@ -0,0 +1,15 @@ +const express = require ('express'); +const app = express (); + +const port = 3000; + +app.get ('/', (req, res) => { + // res.send ('Hello World!'); + res.status (200).json ({ + message: 'It works!', + }); +}); + +app.listen (port, () => + console.log ('Starting server on http://localhost:' + port) +);