Skip to content

Commit f0c6ab8

Browse files
committed
typos
1 parent 070b2df commit f0c6ab8

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

source/integrations/flask-celery-integration.txt

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Setup
8989

9090
- ``app.py``: The main entry point for your Flask application
9191
- ``config.py``: Configuration settings for your application, including
92-
MongoDB connection details, mail server configuration, Celery broker
92+
the MongoDB connection URI, mail server configuration, Celery broker
9393
connection, and any other environment-specific variables
9494
- ``tasks.py``: Defines background tasks to send emails asynchronously
9595
- ``routes.py``: Defines the routes (URLs) that your application responds
@@ -115,11 +115,11 @@ Setup
115115

116116
.. step:: Install the required Python packages
117117

118-
Your application depends on the following libraries:
118+
Your application uses the following libraries:
119119

120120
- `Flask <https://flask.palletsprojects.com/en/stable/>`__ for handling
121121
the web server and routing
122-
- `Flask Mail <https://pypi.org/project/Flask-Mail/>`__ for sending emails
122+
- `Flask-Mail <https://pypi.org/project/Flask-Mail/>`__ for sending emails
123123
from your application
124124
- :ref:`{+driver-short+} <pymongo-get-started-download-and-install>`
125125
- `Celery <https://docs.celeryq.dev/en/stable/>`__ to manage tasks, such
@@ -142,12 +142,12 @@ Setup
142142
Configure Your Application
143143
~~~~~~~~~~~~~~~~~~~~~~~~~~
144144

145-
The ``config.py`` file contains the settings and credentials to perform the
145+
The ``config.py`` file contains settings and credentials to perform the
146146
following actions:
147147

148148
- Connect Celery to RabbitMQ as its message broker
149149
- Configure Flask-Mail to use Gmail as its SMTP server
150-
- Connect your application to your MongoDB server
150+
- Connect your application to your MongoDB deployment
151151

152152
Define the necessary configurations by adding the following code to your
153153
``config.py`` file:
@@ -175,8 +175,8 @@ password to use, rather than using your primary password. For more information,
175175
see the `App Password settings <https://myaccount.google.com/apppasswords>`__ in
176176
your Google Account.
177177

178-
You must also provide a connection string to set into the ``MONGO_URI``
179-
environment variable. For more information see the :ref:`Create a Connection
178+
You must also provide a connection string to set as the ``MONGO_URI``
179+
environment variable. For more information, see the :ref:`Create a Connection
180180
String <pymongo-get-started-connection-string>` section of this guide.
181181

182182
The provided Celery broker URL (``CELERY_BROKER_URL``) specifies RabbitMQ as its
@@ -192,7 +192,7 @@ components.
192192
Initialize Flask, MongoDB, and Celery
193193
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
194194

195-
The ``app.py`` file initializes and configures the core components of the Flask
195+
The ``app.py`` file initializes and configures the core components of your
196196
application. It performs the following tasks:
197197

198198
- Creates a Flask application and loads configuration constants
@@ -251,15 +251,15 @@ app.app_context()`` block. This gives Flask access to other components like the
251251
Flask-Mail ``mail`` instance and the {+driver-short+} connection to your
252252
``newsletter`` MongoDB database.
253253

254-
This method loops through the list of ``subscribers``, creates an email using
254+
This function loops through the list of ``subscribers``, creates an email using
255255
the Flask-Mail ``Message`` class, and then sends it to each user by using the
256256
``mail`` object. After each email is sent, it logs the delivery by inserting a
257257
document into your MongoDB ``deliveries`` collection to record that the message
258-
was sent. Each email operation is wrapped in a ``try`` block to ensure that in
258+
was sent. Each email operation is wrapped in a ``try`` block to ensure that, in
259259
the case of an error, the failure is logged and the database is not updated with
260260
a false delivery record.
261261

262-
Define your ``send_emails()`` method by adding the following code to your
262+
Define your ``send_emails()`` function by adding the following code to your
263263
``tasks.py`` file:
264264

265265
.. code-block:: python
@@ -297,10 +297,10 @@ Define Your Routes
297297
In Flask, the ``@app.route()`` decorator assigns a URL path to a specific
298298
function. In the following code, it is used to define the root (``/``),
299299
``/admin``, ``/subscribe``, and ``/send-newsletters`` routes. The optional
300-
``methods`` parameter is used in some cases to define a list of allowable HTTP
301-
methods.
300+
``methods`` parameter is used in some instances to define a list of allowable
301+
HTTP methods.
302302

303-
The ``@app.before_request()`` method sets a function to run before every
303+
The ``@app.before_request()`` decorator sets a function to run before every
304304
request. In this case, the function provides some basic security by limiting
305305
access to the ``admin`` page to IP addresses listed in the ``ALLOWED_IPS``
306306
parameter defined in the ``config.py`` file. Specifically, access is only
@@ -372,14 +372,14 @@ Define your routes by adding the following code to your ``routes.py`` file:
372372
You can add more security protections or customize user-facing alerts for your
373373
application in this file.
374374

375-
Create Your Pages
376-
~~~~~~~~~~~~~~~~~
375+
Create Your Page Templates
376+
~~~~~~~~~~~~~~~~~~~~~~~~~~
377377

378378
The HTML files in the ``templates`` directory define the user interface, and are
379-
written using standard HTML. Since this application uses asynchronous HTTP
380-
requests, the scripts in these files use :wikipedia:`Fetch API calls
381-
<XMLHttpRequest#Fetch_alternative>`. These scripts also handle timeouts and
382-
errors.
379+
written using standard HTML. Because this application uses asynchronous HTTP
380+
requests, the scripts in these files use `Fetch API calls
381+
<https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API>`__. These scripts
382+
also handle timeouts and errors.
383383

384384
Subscribe Page
385385
```````````````
@@ -446,7 +446,7 @@ Copy the following code into your ``subscribe.html`` file to create your
446446
Admin Page
447447
```````````
448448

449-
The script for the admin page displays an alert to the user that depends on the
449+
The admin page script displays an alert to the user that indicates the
450450
success of the ``send_newsletter`` call.
451451

452452
Copy the following code into your ``admin.html`` file to create your
@@ -644,7 +644,7 @@ You can use the following steps to test your application:
644644

645645
To confirm that you created a new subscriber, open `Atlas
646646
<https://account.mongodb.com/account/login>`__ and navigate to the
647-
``users`` collection in your ``newletter`` database.
647+
``users`` collection in your ``newsletter`` database.
648648

649649
.. step:: Dispatch a newsletter
650650

@@ -669,17 +669,23 @@ Next Steps
669669
~~~~~~~~~~
670670

671671
This application demonstrates how to integrate a Flask application with the
672-
Celery task queue to manage subscriber data, and send batch emails. You can
673-
further enhance this platform by integrating analytics, customizing email
674-
templates, and implementing automated responses.
672+
Celery task queue to manage subscriber data and send batch emails. You can
673+
build on this application to experiment with Flask or Celery. Some possible
674+
improvements include the following changes:
675+
676+
- Add `retries <https://docs.celeryq.dev/en/stable/userguide/calling
677+
html#message-sending-retry>`__ to your ``send_emails`` function
678+
- `Format your newsletter <https://flask-mail.readthedocs.io/en/latest/#sending-messages>`__
679+
- Implement more rigorous `security features <https://docs.celeryq.dev/en/stable/userguide/security.html>`__
675680

676681
More Resources
677682
--------------
678683

679-
For more information about the components used in this tutorial, see the following resources:
684+
For more information about the components used in this tutorial, see the
685+
following resources:
680686

681687
- `Flask <https://flask.palletsprojects.com>`__
682-
- `Flask Mail <https://pypi.org/project/Flask-Mail/#files>`__
688+
- `Flask-Mail <https://pypi.org/project/Flask-Mail/#files>`__
683689
- `Celery <https://docs.celeryq.dev/en/stable/>`__
684690
- `RabbitMQ <https://www.rabbitmq.com/docs/download>`__
685691

0 commit comments

Comments
 (0)