In this assignment, you are tasked with improving upon the translator server you were required to create in the previous assignment. You will improve on it in several ways:
express
module instead of the http
module (you are not allowed to use http
)Take the code that you have for PA 6 and modify the translator.js
server code to use express
instead of http
.
In order to test your changes you should install the express
module on your system, ideally via npm
.
You should not include the installation of express
in your final submission, as that will make the zip file larger than it needs to be.
Before moving on to phase B test the server thoroughly.
Modify the server to be able to serve both static files and dynamic files.
As usual, you should store the static / public files in public_html
.
You should end up with at least three files in this folder: index.html
, a css file, and a js file.
The file structure for this assignment should be:
/server
> translator.js
> Spanish.txt
> German.txt
/public_html
> index.html
> ?.js
> ?.css
When the URL path begins with /translate
, the server should treat it as a translation request.
Any other paths, the server should look for the appropriate static file in public_html
.
You can use the same txt
files from the last PA, or you can download them here:
The client (composed of index.html
, the css file, and the js file) should provide an interface for the user to be able to translate text.
Think of it as a simplified version of google translate.
Take a look at the animations of what it should look like, shown below.
You are required to match at least the same features shown in those animations.
You should use AJAX to make the requests to the server to complete the translations. You should use plain Javascript for the client-side code, and should not use any special js libraries or modules.
Make sure that you take a look at the style guide on the class site before turning in your project.
Specifically, make sure that you validate the HTML, and include header comments.
Also, you should NOT use the http
module for this server.
You should only use the fs
, readline
and express
modules.
The client must use at least one AJAX request, and you should not use any “advanced” js APIs.
You should use the standard XMLHTTPRequest
.
Please see the test cases provided below. You should ensure that your program correctly handles at least these cases correctly. You should not just rely on these though. Try testing the application with other translations too.
yellow airplane
-> gelb flugzeug
absolutely loud big blizzard
-> völlig laut gross schneesturm
klein stadt
-> small town
orange drink
-> la naranja el refresco
conseguilbe atalaya
-> attainable beacon
negro azul
-> schwarze blau
gelb
-> amarillo
For this assignment, you should zip up the entire server
directory and submit that to Gradescope.
The project is due by 7pm on Friday, October 13th, 2023.
The project deadline has been extended until 7pm on Monday, October 16th, 2023.