10.1P: Server Database for Website
Project
Task
In this task, you are required to create a web server that implements a simple
Comments Server, with an interface to a simple database (file) and accepts
requests from a user (client browser). These requests include a GET to display the
contents of the database, and a POST to store a new record in the database.
The database structure (schema) should support a record with the following fields:
Name Type
Name TEXT
Title
TEXT
Comment TEXT
email TEXT
Steps
Task 10.1P
To complete this task, you are required to:
1. Make a standalone Node.js program (i.e., a createDB.js file) and execute it on
the Node.js console to create and initialise a server side SQlite3 file database
in the server folder. The database contains a table that is used to store the
data sent from a form page of your own website (as described in the table
above).
2. Make another Node.js program (i.e., a server.js file) in your Node.js server
folder. This program is able to launch the server, accept the data sent from a
form page of your website (in a POST request), save the received data into
the database table, and display the table data upon the request from the client
(i.e., a GET request).
3. Make necessary changes to a form page of your website (can be stored in a
file index.html), so that it is also able to send a data retrieval request (e.g., a
GET request message linked to a Get Users button) to the server in addition
to sending the form data to the server using a POST message linked to a
Save User button.
4. Launch the server by executing the Node.js program you made.
5. Visit the form web page of your website via the local Node.js server (e.g.,
2022/T1
1/2 SIT774 Web Technologies and Development
http://localhost: 3000/ which will retrieve the index.html page) using a web
browser.
6. Enter data into the form and submit the form to the server (one or more
times, by clicking a Save User button). The data should be saved in the
server database table.
7. Within the form page, send a data retrieval request (e.g., by clicking a Get
Users button) to the server. After receiving the request, the server retrieves
data from the database table and displays the retrieved data in the browser.
Hints
Task 10.1P
This task is similar to the example provided in the unit site. You will note
the structure of the database table will be different (slightly) and there will
need to be a change to the form inputs to match the `fields' expected in the
database.
What will you submit?
You should submit:
• Source code of the form web page of your website.
• Source code of the Node.js file (i.e., the first createDB.js file) that creates a
server file database with a table in it.
• Source code of the Node.js server program file (i.e., the second server.js file).
• Screenshot of the browser window showing the form web page with entered
data.
• Screenshot of the browser window showing the retrieved data from the
database table after the data retrieval request is sent to the server.
2022/T1
2/2