With server and client running, user enters a number into the textbox and clicks "Submit". Prime numbers lesser than or equal to the entered number are calculated on the server, and the median array element(s) are returned to the client.
Uses Sieve of Eratosthenes for calculating primes.
E.g. user enters 10
, so 2,3,5,7
are primes which means 3,5
are returned.
Backend: Express.js/Node.js
Frontend: HTML, CSS, JavaScript, React
Most errors occur when there is bad input or the server isn't running. These errors come in the form of HTTP code 400 (Bad Request). If the number entered is too large, too small, or negative, the error message lets the user know that the number entered doesn't have any valid primes.
Otherwise, i.e. with the server not running, a standard "Bad Request" error message is displayed.
npm
package manager- Run
npm install
to installpackage.json
packages - Run
npm start
from root directory, andnode server.js
from thesrc/server/
directory
The code is 100% commented, so feel free to peruse!