angular-http-server
Version:
Simple http server for developers of apps with client side routing
37 lines (33 loc) • 1.18 kB
HTML
<html>
<head>
<meta charset="utf-8" />
<title>Example</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<div class="container">
<h1>Single Page App HTTP Server</h1>
<p>Up and running in this directory. Enjoy the pictures.</p>
<img src="image.svg" alt="" width="500px" alt="example" />
<img src="beach.jpg" alt="" width="500px" alt="beach" />
<p>This <a href="/../../etc/passwd">link</a> should not work</p>
<button id="get-data">Get some data using the proxy</button>
<div id="data"></div>
</div>
</body>
<script>
const options = {
method: "GET",
headers: {},
};
const btn = document.querySelector("#get-data");
const dataDiv = document.querySelector("#data");
btn.addEventListener("click", () => {
fetch("/todos/1", options)
.then((res) => res.json())
.then((d) => (dataDiv.innerHTML = JSON.stringify(d)))
.catch(console.error);
});
</script>
</html>