This is a node.js code for a web server application built using the Express framework. The application serves a webpage that allows users to search for information by sending a search query to the server. The code integrates with two external APIs (Wikipedia and DuckDuckGo) to retrieve search results.
- A simple and clean user interface for searching information
- Integration with two external APIs for retrieving search results
- Dynamic HTML pages generated by the EJS templating engine
- Error handling for invalid search queries
- Clone the repository
git clone https://github.com/JohnAndreop/Wikipedia-Searcher.git
- Install the dependencies
npm install
- Start the server
npm start
- Open a web browser and go to http://localhost:3000
- Enter a search query and click the "Search" button
The code starts by requiring the necessary modules, including the Express framework and the Undici module, which is used to handle HTTP requests. The code then sets up the Express application by enabling JSON parsing and setting the view engine to EJS. The views folder, where the EJS templates are stored, is also set up.
The assets folder, where static files such as CSS and images are stored, is also set up and made available through the '/assets' endpoint.
The code sets up two endpoints for handling requests:
- The '/' endpoint, which serves the index page of the application.
- The '/search' endpoint, which is responsible for handling the search functionality.
- express
- path
- undici
- ejs
- Node.js
- npm
- Express
- Undici
- EJS