To launch the application follow the steps:
-
Install Node.js and npm: If you haven't already, make sure you have Node.js and npm installed on your machine. You can download them from the official Node.js website: https://nodejs.org. The project is made on Node v16.17.0 and npm v8.15.0 but may try newer versions
-
Install Dependencies: In your project directory, run the following command to install the required packages:
npm install
-
Set Environment Variables: Open your terminal and set your OpenAI API key as an environment variable. Replace
'YOUR_OPENAI_API_KEY'
with your actual OpenAI API key.For Unix-like systems (Linux, macOS):
export OPENAI_API_KEY=YOUR_OPENAI_API_KEY
For Windows (Command Prompt):
set OPENAI_API_KEY=YOUR_OPENAI_API_KEY
For Windows (PowerShell):
$env:OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
-
Run the Application: To run the application, in your terminal, run the following command:
npm start
-
Access the Application: Once the server is running, you can access the application by opening your web browser and navigating to http://localhost:3000. This should display the form where you can input a sentence. After submitting the form, the corrected sentence should be displayed below the form.
-
Test Endpoints: You can also test the different endpoints using tools like cURL or a tool like Postman. Here are some example requests:
-
To fetch random sentence:
curl http://localhost:3000/random
-
To fetch all corrections from the database:
curl http://localhost:3000/corrections
-
-
Cleanup: If you're done testing, you can stop the application by pressing
Ctrl + C
in your terminal.
That's it! With these steps, you should be able to launch and test the application.