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: articles/azure-app-configuration/howto-variant-feature-flags-python.md
+38-42Lines changed: 38 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,14 +49,12 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
49
49
50
50
## Create the Quote of the Day app
51
51
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.
@@ -84,7 +82,7 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
84
82
app.register_blueprint(routes.bp)
85
83
```
86
84
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.
88
86
89
87
```python
90
88
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
180
178
return redirect(url_for("pages.index"))
181
179
```
182
180
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.
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.
214
182
215
183
```html
216
184
<!DOCTYPE html>
@@ -282,7 +250,35 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
282
250
</html>
283
251
```
284
252
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.
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.
286
282
287
283
```html
288
284
{% extends 'base.html' %}
@@ -301,7 +297,7 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
301
297
{% endblock %}
302
298
```
303
299
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.
305
301
306
302
```html
307
303
{% extends 'base.html' %}
@@ -320,7 +316,7 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
320
316
{% endblock %}
321
317
```
322
318
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.
324
320
325
321
```css
326
322
html {
@@ -422,7 +418,7 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
422
418
pip install featuremanagement[AzureMonitor]
423
419
```
424
420
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.
426
422
427
423
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 timefor the permission to propagate before running your application.
428
424
@@ -453,7 +449,7 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
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.
457
453
458
454
```python
459
455
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
475
471
476
472
## Build and run the app
477
473
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.
479
475
480
476
If you use the Windows command prompt, run the following command and restart the command prompt to allow the change to take effect:
481
477
@@ -516,7 +512,7 @@ If you already have a Python Flask web app, you can skip to the [Use the variant
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.
520
516
521
517
:::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.":::
0 commit comments