Skip to content

Commit 058443c

Browse files
committed
review comments
1 parent 859b8d6 commit 058443c

File tree

1 file changed

+38
-42
lines changed

1 file changed

+38
-42
lines changed

articles/azure-app-configuration/howto-variant-feature-flags-python.md

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,12 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
4949

5050
## Create the Quote of the Day app
5151

52-
1. Create a new file named *app.py* in the *QuoteOfTheDay* folder.
52+
1. Create a new file named `app.py` in the `QuoteOfTheDay` folder with the following content. It sets up a basic Flask web application with user authentication.
5353

5454
```python
5555
from flask_bcrypt import Bcrypt
56-
5756
from flask_sqlalchemy import SQLAlchemy
5857
from flask_login import LoginManager
59-
6058
from flask import Flask
6159
6260
app = Flask(__name__, template_folder="../templates", static_folder="../static")
@@ -84,7 +82,7 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
8482
app.register_blueprint(routes.bp)
8583
```
8684
87-
1. Create a new file called *model.py* in the *QuoteOfTheDay* folder.
85+
1. Create a new file named *model.py* in the *QuoteOfTheDay* folder with the following content. It defines a `Quote` data class and a user model for the Flask web application.
8886
8987
```python
9088
from dataclasses import dataclass
@@ -180,37 +178,7 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
180178
return redirect(url_for("pages.index"))
181179
```
182180
183-
1. Create a new folder named *templates* in the *QuoteOfTheDay* folder.
184-
185-
1. Create a new file named *index.html* in the *templates* folder.
186-
187-
```html
188-
{% extends 'base.html' %}
189-
190-
{% block content %}
191-
<div class="quote-container">
192-
<div class="quote-content">
193-
{% if model.greeting_message %}
194-
<h3 class="greeting-content">{{model.greeting_message}}</h3>
195-
{% endif %}
196-
<br />
197-
<p class="quote">“{{model.quote.message}}”</p>
198-
<p>- <b>{{model.quote.author}}</b></p>
199-
</div>
200-
201-
<div class="vote-container">
202-
<button class="btn btn-primary" onclick="heartClicked(this)">
203-
<i class="far fa-heart"></i> <!-- Heart icon -->
204-
</button>
205-
</div>
206-
207-
<form action="/" method="post">
208-
</form>
209-
</div>
210-
{% endblock %}
211-
```
212-
213-
1. Create a new file named *base.html* in the *templates* folder.
181+
1. Create a new folder named *templates* in the *QuoteOfTheDay* folder and add a new file named *base.html* in it with the following content. It defines the layout page for the web application.
214182
215183
```html
216184
<!DOCTYPE html>
@@ -282,7 +250,35 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
282250
</html>
283251
```
284252
285-
1. Create a new file named *sign_up.html* in the *templates* folder.
253+
1. Create a new file named *index.html* in the *templates* folder with the following content. It extends the base template and adds the content block.
254+
255+
```html
256+
{% extends 'base.html' %}
257+
258+
{% block content %}
259+
<div class="quote-container">
260+
<div class="quote-content">
261+
{% if model.greeting_message %}
262+
<h3 class="greeting-content">{{model.greeting_message}}</h3>
263+
{% endif %}
264+
<br />
265+
<p class="quote">“{{model.quote.message}}”</p>
266+
<p>- <b>{{model.quote.author}}</b></p>
267+
</div>
268+
269+
<div class="vote-container">
270+
<button class="btn btn-primary" onclick="heartClicked(this)">
271+
<i class="far fa-heart"></i> <!-- Heart icon -->
272+
</button>
273+
</div>
274+
275+
<form action="/" method="post">
276+
</form>
277+
</div>
278+
{% endblock %}
279+
```
280+
281+
1. Create a new file named *sign_up.html* in the *templates* folder with the following content. It defines the template for the user registration page.
286282
287283
```html
288284
{% extends 'base.html' %}
@@ -301,7 +297,7 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
301297
{% endblock %}
302298
```
303299
304-
1. Create a new file named *login.html* in the *templates* folder.
300+
1. Create a new file named *login.html* in the *templates* folder with the following content. It defines the template for the user login page.
305301
306302
```html
307303
{% extends 'base.html' %}
@@ -320,7 +316,7 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
320316
{% endblock %}
321317
```
322318
323-
1. Create a new folder named *static* in the *QuoteOfTheDay* folder and add a new file named *site.css* in it.
319+
1. Create a new folder named *static* in the *QuoteOfTheDay* folder and add a new file named *site.css* in it with the following content. It adds CSS styles for the web application.
324320
325321
```css
326322
html {
@@ -422,7 +418,7 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
422418
pip install featuremanagement[AzureMonitor]
423419
```
424420
425-
1. Open `app.py` to connect to App Configuration and set up feature management.
421+
1. Open `app.py` and add the following code to connect to App Configuration and set up feature management.
426422
427423
You use the `DefaultAzureCredential` to authenticate to your App Configuration store. Follow the [instructions](./concept-enable-rbac.md#authentication-with-token-credentials) to assign your credential the **App Configuration Data Reader** role. Be sure to allow sufficient time for the permission to propagate before running your application.
428424
@@ -453,7 +449,7 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
453449
feature_manager = FeatureManager(azure_app_config)
454450
```
455451
456-
1. Open `routes.py` to refresh configuration and get the feature variant.
452+
1. Open `routes.py` and add the following code to refresh configuration and get the feature variant.
457453
458454
```python
459455
from featuremanagement.azuremonitor import track_event
@@ -475,7 +471,7 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
475471
476472
## Build and run the app
477473
478-
1. Set an environment variable. Set the environment variable named **AzureAppConfigurationEndpoint** to the endpoint of your App Configuration store found under the *Overview* of your store in the Azure portal.
474+
1. Set an environment variable named **AzureAppConfigurationEndpoint** to the endpoint of your App Configuration store found under the *Overview* of your store in the Azure portal.
479475
480476
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
481477
@@ -516,7 +512,7 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
516512
517513
1. Register a second user named *[email protected]*.
518514
519-
1. You're' automatically logged in. You should see that [email protected] sees the short message when viewing the app.
515+
1. You're automatically logged in. You should see that [email protected] sees the short message when viewing the app.
520516
521517
:::image type="content" source="media/use-variant-feature-flags-python/message.png" alt-text="Screenshot of the Quote of the day app, showing a message for the user.":::
522518

0 commit comments

Comments
 (0)