City Rate is an Express.js application that displays a random city from a CSV file (enhanced by Wikipedia details) and allows users to rate the city. Ratings are stored in a local SQLite database.
- Random City Generation: Pulls a random city from a CSV file and fetches relevant Wikipedia details such as a title, summary, and image.
- Rating System: Allows users to assign star ratings to the displayed city.
- SQLite Database: Stores and retrieves city ratings locally using SQLite.
- Express.js: Utilizes a simple Node + Express server for RESTful routes.
-
Clone the repository:
git clone https://github.com/your-username/your-repo.git cd your-repo
-
Install dependencies:
npm install
-
(Optional) Create/Update the
worldcities.csv
file:- The app reads city names from a CSV file (in
../data/worldcities.csv
relative tocityGen.js
). - Ensure that the CSV contains a column named
city
for the city names.
- The app reads city names from a CSV file (in
-
Start the server:
npm start
The server should be running at
http://localhost:3000
.
- Open your web browser and navigate to
http://localhost:3000
. - A random city will be displayed, pulled from your
worldcities.csv
file and enriched with Wikipedia data. - Rate the city using the star buttons. Your rating will be saved to the SQLite database.
- Click "Get another city" to fetch a new random city.
- To directly fetch details for a specific city, navigate to
http://localhost:3000/cityName=<CityName>
. - Replace
<CityName>
with the desired city name. The application will attempt to fetch and display its Wikipedia details, if available.
-
GET /
- Renders the random city page.
-
GET /getRatings?cityName=CITY_NAME
- Retrieves stored ratings for
CITY_NAME
.
- Retrieves stored ratings for
-
POST /addRating
- Body Parameters:
cityName
: The name of the city to rate.rating
: The numeric rating (1 to 5).
- Adds a rating to the database.
- Body Parameters:
-
GET /cityName=:cityName
- Fetches and displays details for the given city name directly, if it exists in Wikipedia.