Skip to content

Commit 154dac9

Browse files
authored
feat: add dev container and docs (#1)
1 parent 8a53ddc commit 154dac9

File tree

4 files changed

+44
-54
lines changed

4 files changed

+44
-54
lines changed

Diff for: .devcontainer/devcontainer.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Adopting the default GitHub codespaces-jupyter template as starter
2+
// https://github.com/github/codespaces-jupyter
3+
4+
{
5+
"name" : "Flask with PostgreSQL",
6+
"image": "mcr.microsoft.com/devcontainers/universal:2",
7+
"hostRequirements": {
8+
"cpus": 2,
9+
"memory": "8gb",
10+
"storage": "32gb"
11+
},
12+
"waitFor": "onCreateCommand",
13+
"updateContentCommand": "python3 -m pip install -r requirements.txt",
14+
"postCreateCommand": "",
15+
"customizations": {
16+
"codespaces": {
17+
"openFiles": ["README.md"]
18+
},
19+
"vscode": {
20+
"extensions": [
21+
"ms-python.python"
22+
]
23+
}
24+
}
25+
}

Diff for: README.md

+19-54
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
1-
# flask-webapp-postgresql-db
1+
# Python (Flask) Web App with PostgreSQL and Key Vault
22

3-
Artists Booking Venues powered by Python (Flask) and PostgreSQL Database
3+
Artists Booking Venues powered by Python (Flask) and PostgreSQL Database.
4+
There is no user authentication or per-user data stored.
45

5-
## Development Setup
6+
![Screenshot of website landing page](./repo-thumbnail.png)
67

7-
1. **Download the project starter code locally**
8+
The project is designed for deployment on Azure App Service with a PostgreSQL flexible server. See deployment instructions below.
89

9-
```bash
10-
git clone https://github.com/john0isaac/flask-webapp-postgresql-db.git
11-
cd flask-webapp-postgresql-db
12-
```
10+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/john0isaac/flask-webapp-postgresql-db?devcontainer_path=.devcontainer/devcontainer.json)
1311

14-
2.**Before and After editing your code, Use the commands below:**
12+
![Architecture Diagram: App Service, PostgreSQL server, Key Vault](./architecture-diagram.png)
1513

16-
before editing anything pull new changes from GitHub.
14+
## Local Development
1715

18-
```bash
19-
git pull
20-
```
2116

22-
Once you are done editing, you can push the local repository to your Github account using the following commands.
17+
1. **Download the project starter code locally**
2318

24-
```bash
25-
git add .
26-
git commit -m "your comment message"
27-
git push
28-
```
19+
```bash
20+
git clone https://github.com/john0isaac/flask-webapp-mysql-db.git
21+
cd flask-webapp-mysql-db
22+
```
2923

30-
3.**Initialize and activate a virtualenv using:**
24+
2.**Initialize and activate a virtualenv using:**
3125

3226
```bash
3327
python -m virtualenv venv
@@ -41,13 +35,13 @@ source venv/Scripts/activate
4135
deactivate
4236
```
4337

44-
4.**Install the dependencies:**
38+
3.**Install the dependencies:**
4539

4640
```bash
4741
pip install -r requirements.txt
4842
```
4943

50-
5.**Run the development server:**
44+
4.**Run the development server:**
5145

5246
```bash
5347
export FLASK_APP=app.py
@@ -56,40 +50,11 @@ export FLASK_DEBUG=true
5650
flask run --reload
5751
```
5852

59-
6.**Verify on the Browser**
53+
5.**Verify on the Browser**
6054

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

63-
## Adding Routes
64-
65-
- Create the html, css, js in the specified folder using the same folder structure.
66-
- Create a new route in the [app.py](./app.py) file with the name you want using only dashes to separate words.
67-
68-
```PYTHON
69-
@app.route('NEW-ROUTE')
70-
```
71-
72-
- Define your serving function using a unique name not used before in the whole application.
73-
74-
```PYTHON
75-
def NEW_UNIQUE_NAME():
76-
```
77-
78-
- Return your html file path using render_template.
79-
80-
```PYTHON
81-
return render_template('FOLDER_PATH/FILE_PATH.html')
82-
```
83-
84-
- Your newly created route should look like this.
85-
86-
```PYTHON
87-
@app.route('NEW-ROUTE')
88-
def NEW_UNIQUE_NAME():
89-
return render_template('FOLDER_PATH/FILE_PATH.html')
90-
```
91-
92-
## Deploying to Google Cloud
57+
## Google Cloud Deployment
9358

9459
1. Open the Google Cloud Shell and execute the following command:
9560

@@ -126,7 +91,7 @@ env_variables:
12691
gcloud app deploy app.yaml
12792
```
12893

129-
## Deploying After Deleting Everything from Google Cloud
94+
### Deploying After Deleting Everything from Google Cloud
13095

13196
1. Create a Cloud SQL instance using the following parameters:
13297
- Specify instance name and password.

Diff for: architecture-diagram.png

142 KB
Loading

Diff for: repo-thumbnail.png

1.57 MB
Loading

0 commit comments

Comments
 (0)