Skip to content

Commit 03cc4d8

Browse files
committed
Remove unnecessary code from the Flask app in tutorial
1 parent e8b9d56 commit 03cc4d8

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

tutorial/03-responding-to-slack-events.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ The code for this step is available [here](PythOnBoardingBot).
1212
```
1313
slackclient>=2.0.0
1414
slackeventsapi>=2.1.0
15-
Flask>=1.1.1
16-
certifi
15+
Flask>=1.1.2
1716
```
1817

1918
> 💡 **[Certifi](https://github.com/certifi/python-certifi)** is a carefully curated collection of Root Certificates for validating the trustworthiness of SSL certificates while verifying the identity of TLS hosts. It has been extracted from the Requests project.
@@ -39,8 +38,6 @@ import logging
3938
from flask import Flask
4039
from slack import WebClient
4140
from slackeventsapi import SlackEventAdapter
42-
import ssl as ssl_lib
43-
import certifi
4441
from onboarding_tutorial import OnboardingTutorial
4542
```
4643

@@ -210,19 +207,25 @@ def message(payload):
210207

211208
Finally, we need to make our app runnable.
212209

213-
- 🏁 Add the following lines of code to the end of `app.py`.
210+
- 🏁 Add the following lines of code to the end of `app.py` and run `FLASK_ENV=development python app.py`.
214211

215212
```Python
216213
if __name__ == "__main__":
217214
logger = logging.getLogger()
218215
logger.setLevel(logging.DEBUG)
219216
logger.addHandler(logging.StreamHandler())
220-
ssl_context = ssl_lib.create_default_context(cafile=certifi.where())
221217
app.run(port=3000)
222218
```
223219

224220
**Note:** When running in a virtual environment you often need to specify the location of the SSL Certificate(`cacert.pem`). To make this easy we use Certifi's built-in `where()` function to locate the installed certificate authority (CA) bundle.
225221

222+
```python
223+
import ssl as ssl_lib
224+
import certifi
225+
226+
ssl_context = ssl_lib.create_default_context(cafile=certifi.where())
227+
```
228+
226229
**Final Note:** If you're interested in learning how to modify this app to run asynchronously I've adapted this code as such [here](PythOnBoardingBot/async_app.py).
227230

228231
---

tutorial/PythOnBoardingBot/app.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
from flask import Flask
44
from slack import WebClient
55
from slackeventsapi import SlackEventAdapter
6-
import ssl as ssl_lib
7-
import certifi
86
from onboarding_tutorial import OnboardingTutorial
97

108
# Initialize a Flask app to host the events adapter
@@ -146,5 +144,4 @@ def message(payload):
146144
logger = logging.getLogger()
147145
logger.setLevel(logging.DEBUG)
148146
logger.addHandler(logging.StreamHandler())
149-
ssl_context = ssl_lib.create_default_context(cafile=certifi.where())
150147
app.run(port=3000)

0 commit comments

Comments
 (0)