Skip to content

Commit

Permalink
Add setup script; Update READEME.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchcamza committed Sep 13, 2024
1 parent 4920bb9 commit 674c232
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 11 deletions.
34 changes: 23 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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/ | | |
Expand Down
25 changes: 25 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 674c232

Please sign in to comment.