Hospital
Hospital
json
[]
2.save it as app.js
const express = require('express');
const fs = require('fs');
const cors = require('cors');
const bodyParser = require('body-parser');
const path = require('path');
app.use(cors());
app.use(bodyParser.json());
app.use(express.static(__dirname)); // Serve static files like index.html
app.listen(PORT, () => {
console.log(`App running at http://localhost:${PORT}`);
});
3.save it as index.html
<!DOCTYPE html>
<html>
<head>
<title>Healthcare Management</title>
<style>
body { font-family: Arial; margin: 40px; }
input, button { margin: 5px; padding: 8px; }
</style>
</head>
<body>
<h1>Healthcare Patient Management</h1>
<script>
async function addPatient() {
const name = document.getElementById('name').value.trim();
const age = document.getElementById('age').value.trim();
const condition = document.getElementById('condition').value.trim();
if (!name || !age || !condition) {
alert('Please fill all fields');
return;
}
await fetch('/patients', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name, age, condition })
});
document.getElementById('name').value = '';
document.getElementById('age').value = '';
document.getElementById('condition').value = '';
loadPatients();
}
loadPatients();
</script>
</body>
</html>
Output