diff --git a/README.md b/README.md index 2f54d58..af4a6a0 100644 --- a/README.md +++ b/README.md @@ -9,45 +9,57 @@ - Contains unit tests - The API can be tested with the Insomnia REST client -## Installation and Usage -To use this application, follow these steps: +## Getting the Code 1. Clone the Repository from GitHub ```bash git clone https://github.com/Meta-Backend-Developer/08-LittleLemon.git ``` -2. Activate the Existing Virtual Environment: +## Installation and Usage + +### Method 1 (Recommended for new users): + +1. Make the `setup.sh` script in the root directory executable: + ```bash + chmod +x setup.sh + ``` +2. Run the Script from the Root Directory: + ```bash + ./setup.sh + ``` + +### Method 2: Follow the setup instructions below: + +1. Activate the Existing Virtual Environment: ```bash python -m venv lemon source lemon/bin/activate # (On Windows use `env\Scripts\activate`) ``` -3. Install Dependencies: +2. Install Dependencies: ```bash pip install -r requirements.txt ``` -4. Database Setup +3. Database Setup The MySQL database is already configured in the settings.py file. If you need to modify the connection details, you can find the relevant settings in the DATABASES section of settings.py. -5. Apply Database Migrations: +4. Apply Database Migrations: ```bash python3 manage.py migrate ``` -6. Run the Development Server: +5. Run the Development Server: ```bash python3 manage.py runserver ``` -7. Test the application using the Insomnia REST client or other tools. - ## Establishing a MySQL connection Note: the 'django.db.backends.mysql' engine does not work on ARM based machines. Please install mysql-connector-python using pip or pipenv. Alternatively, if you are using the mysqlclient connector, you can uncomment the 'django.db.backends.mysql' line in **settings.py** and comment out the line below it, in order to establish a database connection. -## Credentials +### Database Credentials | Username | Password | User Type | |----------|----------------|---------------| | meta | password | superuser | @@ -57,7 +69,7 @@ Alternatively, if you are using the mysqlclient connector, you can uncomment the The application contains unit tests that can be run using the Django test runner. To run the tests, use the following command: ```python manage.py test``` The API can also be tested using the Insomnia REST client or other tools. -## API endpoints to test +### API endpoints to test | Description | Method | Path | Token | Form/JSON payload | |-----------------------|--------|-----------------------------|------------------------------------------|---------------------------------------------------------------------------| | Load static home page | GET | /restaurant/ | | | diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..6688db0 --- /dev/null +++ b/setup.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Step 1: Clone the Repository +echo "Cloning the repository..." +git clone https://github.com/Meta-Backend-Developer/08-LittleLemon.git +cd 08-LittleLemon || exit + +# Step 2: Activate the Existing Virtual Environment +echo "Setting up virtual environment..." +if [ ! -d "lemon" ]; then + python3 -m venv lemon +fi +source lemon/bin/activate + +# Step 3: Install Dependencies +echo "Installing dependencies..." +pip install -r requirements.txt + +# Step 4: Apply Database Migrations +echo "Applying database migrations..." +python3 manage.py migrate + +# Step 5: Run the Development Server +echo "Starting the development server..." +python3 manage.py runserver