Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,46 @@ The project is designed for deployment on Azure App Service with a MySQL flexibl
export FLASK_DEBUG=true
flask run --reload
```

**For Windows, use [`setx`](https://learn.microsoft.com/windows-server/administration/windows-commands/setx) command shown below:**

```powershell
setx FLASK_APP=app.py
setx FLASK_ENV=development
setx FLASK_DEBUG=true
setx FLASK_APP app.py
setx FLASK_ENV development
setx FLASK_DEBUG true
flask run --reload
```

6. **Verify on the Browser**

Navigate to project homepage [http://127.0.0.1:5000/](http://127.0.0.1:5000/) or [http://localhost:5000](http://localhost:5000)

### Connect to your Database locally

This application is configured to work without connecting a database for the pages that doesn't interact with it. If you want to enable database operations you'll need to connect to a database.

- **Run the following commands to connect to a database:**

```bash
export DEPLOYMENT_LOCATION=local
export DB_USER=
export DB_PASSWORD=
export DB_HOST=
export DB_NAME=
```

- **For windows, add configuration using:**

```powershell
setx DEPLOYMENT_LOCATION local
setx DB_USER user
setx DB_PASSWORD password
setx DB_HOST host
setx DB_NAME dbname
```

- **Run the development server again.**

## Deployment

This repository is set up for deployment on Azure App Service (w/MySQL flexible server) using the configuration files in the `infra` folder.
Expand Down
4 changes: 4 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
print("Loading environment.azure_production.")
app.config.from_object('environment.azure_production')
setup_db(app)
elif os.environ.get('DEPLOYMENT_LOCATION') == 'local':
print("Loading environment.development.")
app.config.from_object('environment.development')
setup_db(app)
else:
print("No environment detected.")

Expand Down
9 changes: 9 additions & 0 deletions environment/development.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os

# mysql+mysqlconnector://your-username:your-password@localhost/your-schema'
DATABASE_URI = 'mysql+mysqlconnector://{dbuser}:{dbpass}@{dbhost}/{dbname}'.format(
dbuser=os.environ.get('DB_USER'),
dbpass=os.environ.get('DB_PASSWORD'),
dbhost=os.environ.get('DB_HOST'),
dbname=os.environ.get('DB_NAME')
)