You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: samples/app/flask/README.md
+23-3Lines changed: 23 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,15 +32,35 @@ config = {
32
32
33
33
Then save api.py.
34
34
35
-
### 3. Install Python modules
35
+
### 3. Set up and activate a virtual environment <aname="activate"></a>
36
+
37
+
A virtual environment is a directory tree which contains Python executable files and other files which indicate that it is a virtual environment. Basically, it's the backbone for running your Python Flask app.
38
+
39
+
Creation of [virtual environments](https://docs.python.org/3/library/venv.html?ref=hackernoon.com#venv-def) is done by executing the following command:
40
+
41
+
```
42
+
$ python3 -m venv venv
43
+
```
44
+
45
+
**Tip**: Tip: pyvenv is only available in Python 3.4 or later. For older versions please use the [virtualenv](https://virtualenv.pypa.io/en/latest/) tool.
46
+
47
+
Before you can start installing or using packages in your virtual environment, you’ll need to activate it. Activating a virtual environment will put the virtual environment-specific python and pip executables into your shell’s PATH.
48
+
49
+
Activate the virtual environment using the following command:
50
+
51
+
```bash
52
+
$ . venv/bin/activate activate
53
+
```
54
+
55
+
### 4. Install Python modules
36
56
37
57
Open a terminal window and install the MariaDB and Flask modules.
38
58
39
59
```bash
40
60
$ pip install mariadb flask
41
61
```
42
62
43
-
### 4. Start the API project
63
+
### 5. Start the API project
44
64
45
65
```bash
46
66
$ python api.py
@@ -50,4 +70,4 @@ That's it! You should now having a running Python/Flask API project. You can tes
50
70
51
71
## More Resources
52
72
53
-
*[Getting Started with MariaDB using Docker, Python and MariaDB](https://dev.to/probablyrealrob/getting-started-with-mariadb-using-docker-python-and-flask-38a7) (blog)
73
+
*[Getting Started with MariaDB using Docker, Python and MariaDB](https://dev.to/probablyrealrob/getting-started-with-mariadb-using-docker-python-and-flask-38a7) (blog)
0 commit comments