Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
22 views
7 pages
2
Uploaded by
Bruna Oliveira
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save 2 For Later
Download
Save
Save 2 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
22 views
7 pages
2
Uploaded by
Bruna Oliveira
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save 2 For Later
Carousel Previous
Carousel Next
Download
Save
Save 2 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 7
Search
Fullscreen
CHAPTER 7 — MONITORING FLASK APPLICATIONS Flask-WhooshAlchemy Whoosh is a fast, search engine library built in Python and is highly flexible and supports complex data searching based on free-form or structured text. Flask-WhooshAlchemy is a Flask extension to integrate the Whoosh search engine library with SQLAlchemy in Flask. It’s pretty straightforward to integrate and get your full text search up without any third-party application unlike pyelasticsearch. You can learn more about it at https: //pythonhosted.org/Flask-WhooshAlchemy/ We used Flask mail for verifying user emails. Here is a list of other libraries you can use for efficient email integration in your application. Flask-SendGrid Flask-SendGrid is a Flask extension to simplify sending email using sendgrid which is a renowned email service; you can sign up for SendGrid at https: //sendgrid. com/; they provide a free subscription which includes 40,000 emails for first 30 days and 100/day forever. You can check out Flask SendGrid at https: //github. com/frankv/flask-sendgrid which makes sending email a piece of cake. AWS SNS Using Boto3 Boto3 is an AWS SDK for Python, and you can use AWS’ SNS (Simple Notification Service) to send email and text message using Boto. Here is a guide to sending email using Python with Boto https: //docs.aws. amazon. com/ses/latest/DeveloperGuide/send-using-sdk-python. html. You'll need an active AWS account for this and Boto installed from https: //boto3.readthedocs. io/en/latest/guide/quickstart. html#installation. 193CHAPTER 7 MONITORING FLASK APPLICATIONS. File Storage File storage is an important aspect of an application; we stored user avatars in an application server file system which is not a good approach for production applications, and in such cases you’d like to store and access your files using afile storage service. Here are a handful of suggestions for the same. AWS $3 Using Boto3 You can leverage Boto3 to manage your files on Amazon AWS S3, which is a powerful file management system. This guide will provide you with everything you need to manage your files using Flask https : //boto3 . amazonaws . com/v1/documentation/api/latest/reference/services/ s3.html Alibaba Cloud OSS Alibaba Cloud provides a sophisticated file storage platform called Object Storage Service; you can use their Python SDK from https: //github. com/aliyun/aliyun-oss-python-sdk and easily setup file management using their OSS guide which is available at https: //help.aliyun.com/ document_detail/32026. html Conclusion This marks the end of this chapter and the book. There is a lot more to explore in optimizing and upgrading your application, but this will serve as the right base to grow from; if you have issues in integrating any of the mentioned services, check out their official docs, reach out to support, or reach out on Stack Overflow to solve them. You can also use this link to ask or read queries regarding Flask https : //stackoverflow. com/ search?q=flask. 194Index A,B Alibaba Cloud ECS Console, 161 Amazon AWS $3, 194 Assertion methods, 140 c Caching, 13 Create, Read, Update, and Delete (CRUD), 4 CRUD application adds global responses, 71, 72 API documentation building blocks, 115 OAS see (OpenAPI Specification (OAS)) application structure, 64 author route blueprint registration, 78 blueprints, 60 create authors model, 65, 66 create books model, 64 create __init_.py, 62 create responses.py inside api/utils, 67 creating POST book endpoint, 79 db.init_app function, 70 © Kunal Relan 2019 DELETE endpoints, 77, 84, 85 email verification create_user() method, 104, 105 flask-mail library installation, 103 GET endpoint, 102 login method, 101 token.py, 100 URLSafeTimedSerializer, 101 User class code, 98, 99 User email verification, 108 User login after verification, 108 User login without verification, 107 user signup API, 106, 107 users.py in models, 98 fetch author ID, 76, 80 file upload add avatar field, 109, 111 avatar endpoint with invalid file type, 114 avatar field endpoint, 112 fetch avatar endpoint, 113 GET author endpoint, 81, 82 GET authors route, 75 GET books endpoint, 86 K. Relan, Building REST APIs with Flask, https:/ /doi.org/10.1007/978-1-4842-5022-8INDEX CRUD application (cont.) HTTP responses, 68 import create_app, 61 PATCH endpoint, 83 POST author route, 73 POST authors endpoint, 74 PUT author endpoint, 82 user authentication create POST user route, 91 create schema, 88, 89 Flask-JWT-Extended, 89 login endpoint, 94 POST author route, 95, 96 POST users endpoint, 93 user signup endpoint, 93 Database modelling creating author database, 34 db.create_all(), 34 DELETE author by ID, 43-45 GET all authors, 39 GET author by ID endpoint, 40 GET/authors response, 36, 37 POST/authors endpoint, 38 PUT endpoint, 41, 42 RESTful CRUD APIs, 33 Flask-SQLAlchemy, 30-32 MongoEngine application create db instance, 47, 48 create PUT endpoint, 54, 55 196 CRUD application, 56-58 delete endpoint, 55 GET endpoint, 48, 50 installation, 47 JSON data, 51 requesting POST /authors, 51,52 MySQL vs MongoDB, 29 NoSQL databases, 28 SQLAlchemy, creating author database, 34 SQL databases, 28 db.init_app function, 70 Deploying applications Alibaba Cloud ECS GitHub repo, 162 Gunicorn, 167-169, 171 Nginx, 160, 162, 164-167 syntax errors, 166 Ubuntu instance, 160, 162 uWSGI, 160, 162, 164-167 AWS Elastic Beanstalk, 172 Google Cloud App Engine, 180-182 Heroku Gunicorn, 177-179 PaaS, 176 Procfile, 177-179 Elastic Beanstalk application AWS, 172 configuration, 174deployed flask app, 176 eb create, 173 environment variables, 175 WSGlpath set, 174 F find_by_username() method, 92 Flask application, 2, 3 components, 1-4 installation, 25 python development environment IDE setup, 18, 19 PIP installation, 16-18 running virtual application, 23, 24 virtual directory structure, 21,22 virtualeny, 20 SQLAlchemy, 4 Flask Monitoring Dashboard, 187 Flask-SQLAlchemy, 30 Flask-WhooshAlchemy, 193 G,H Google Cloud App Engine, 180-182 _init__py, 62 INDEX J, KL JSON Web Tokens (JWT), 89 Monitoring flask applications bonus services emails, 193, 194 Flask-WhooshAlchemy, 193 Pyelasticsearch, 192 flask monitoring dashboard, 187, 188 New Relic, 189-191 Sentry, 185-187 N New Relic, 189 O° Object Document Mapper (ODM), 28 Object Relational Mapper (ORM), 28 Object Storage Service (OSS), 194 OpenAPI Specification (OAS), 116 API request mode, 124 build time documentation author avatar endpoint, 132-134 create author endpoint, 130, 131 197INDEX OpenAPI Specification (OAS) (cont) create user endpoint, 126, 127 Swagger UI, 128 using YAML, 127 definition, 116 importing OpenAPI from Inspector, 121 login endpoint, 119 pinned requests, 119 spec generation, 120 SwaggerHub, 122 Swagger Inspector, 117, 118 Swagger UI, 125 view documentation, 122, 123 P,Q Platform as a Service (PaaS), 176 Pyelasticsearch, 192 Python Package Index (PPI), 2 R render_template_string method, 104 Representational State Transfer (REST) API design, 15, 16 architecture, 6 definition, 4 services 198 caching technique, 13 messages, 9-12 planning, 14, 15 representation, 8 resources, 12 statelessness, 14 uniform interface, 7 used HTTP verbs, 8 SOAP, 6 response_with function, 70 Ss Sentry, 185 Simple Object Access Protocol (SOAP), 6 Structured Query Language (SQL), 28 T test_login_unverified_user() method, 143 test_login_user_wrong_credentials method, 143 U Unit testing benefits, 136 setting up, 136-138 test coverage, 155 user endpointsassertion methods, 140 authors test, 151, 153, 155 create temp image file, 149 create test_authors.py, 146 create_user endpoint, 143, 144 create_users() method, 144 creating author without last_name field, 148 CSV file, 149 delete author object, 151 generate login token, 146 GET author ID, 150 POST author endpoint, 147 INDEX running with nose, 142 SQLAlchemy model, 139 test login API, 142 TestUsers() class, 140 test_users.py, 139 update author object, 150 Virtualeny, 20 W, X, Y, Z Web Server Gateway Interface (WSGI), 1
You might also like
5
PDF
No ratings yet
5
1 page
4
PDF
No ratings yet
4
1 page
3
PDF
No ratings yet
3
1 page
B
PDF
No ratings yet
B
1 page
1
PDF
No ratings yet
1
1 page
Kanro T. Python Flask Vue - Js PostgreSQL PyCharm. 200 Things... Beginners... 2024
PDF
No ratings yet
Kanro T. Python Flask Vue - Js PostgreSQL PyCharm. 200 Things... Beginners... 2024
495 pages
Flask Restx Readthedocs Io en Latest
PDF
No ratings yet
Flask Restx Readthedocs Io en Latest
95 pages
Flask Docs
PDF
No ratings yet
Flask Docs
306 pages
Flask Doc PDF Gen Readthedocs Io en Latest
PDF
No ratings yet
Flask Doc PDF Gen Readthedocs Io en Latest
325 pages
Flask Restx Readthedocs Io en Latest
PDF
No ratings yet
Flask Restx Readthedocs Io en Latest
95 pages
flask notes
PDF
No ratings yet
flask notes
3 pages
Flask Restful Readthedocs Io en 0.3.7
PDF
No ratings yet
Flask Restful Readthedocs Io en 0.3.7
50 pages
Build SPA With React and Wagtail
PDF
No ratings yet
Build SPA With React and Wagtail
170 pages
Michael Yin - The Definitive Guide Next - Js Wagtail-Leanpub (2021)
PDF
No ratings yet
Michael Yin - The Definitive Guide Next - Js Wagtail-Leanpub (2021)
216 pages
CherryPy v.18.0.2
PDF
No ratings yet
CherryPy v.18.0.2
213 pages
Flask
PDF
No ratings yet
Flask
293 pages
Flask
PDF
No ratings yet
Flask
293 pages
Chalice
PDF
No ratings yet
Chalice
134 pages
EXP3
PDF
No ratings yet
EXP3
10 pages
Flask Docs
PDF
No ratings yet
Flask Docs
207 pages
How To Build A REST API With Flask
PDF
No ratings yet
How To Build A REST API With Flask
4 pages
Flask Documentation (PDFDrive)
PDF
No ratings yet
Flask Documentation (PDFDrive)
259 pages
scrib3
PDF
No ratings yet
scrib3
6 pages
Explore Flask
PDF
100% (1)
Explore Flask
79 pages
Slides16 Flask
PDF
No ratings yet
Slides16 Flask
35 pages
Flask Docs
PDF
No ratings yet
Flask Docs
344 pages
Flask Docs
PDF
No ratings yet
Flask Docs
273 pages
Python Flask Framework & RESTful APIs - A Practical Guide
PDF
No ratings yet
Python Flask Framework & RESTful APIs - A Practical Guide
9 pages
Flask Docs
PDF
No ratings yet
Flask Docs
267 pages
Flask
PDF
No ratings yet
Flask
280 pages
Michael Yin - Build Blog With React DDR Wagtail (2021)
PDF
No ratings yet
Michael Yin - Build Blog With React DDR Wagtail (2021)
167 pages
Flask Guide
PDF
No ratings yet
Flask Guide
77 pages
PPFD_4
PDF
No ratings yet
PPFD_4
45 pages
Flask
PDF
No ratings yet
Flask
16 pages
Lecture 6 Create REST API
PDF
No ratings yet
Lecture 6 Create REST API
13 pages
Flask Basics
PDF
No ratings yet
Flask Basics
14 pages
Docs Cherrypy Dev en Latest
PDF
No ratings yet
Docs Cherrypy Dev en Latest
273 pages
Flask RestApi and SqlAlchemy
PDF
No ratings yet
Flask RestApi and SqlAlchemy
22 pages
Ua Pycon 2012
PDF
No ratings yet
Ua Pycon 2012
65 pages
Flask Blueprints - Sample Chapter
PDF
No ratings yet
Flask Blueprints - Sample Chapter
37 pages
Assessment 3
PDF
No ratings yet
Assessment 3
17 pages
Hand Lettering Letterform Template
PDF
No ratings yet
Hand Lettering Letterform Template
5 pages
Python Dev Web Ser
PDF
No ratings yet
Python Dev Web Ser
9 pages
Flask
PDF
No ratings yet
Flask
4 pages
Cherry Py
PDF
No ratings yet
Cherry Py
89 pages
Cloud Computing Practical3
PDF
No ratings yet
Cloud Computing Practical3
7 pages
Building Beautiful Restful Apis Using Flask 1
PDF
No ratings yet
Building Beautiful Restful Apis Using Flask 1
34 pages
Interview Task
PDF
No ratings yet
Interview Task
6 pages
3
PDF
No ratings yet
3
3 pages
Lamp and Rest
PDF
No ratings yet
Lamp and Rest
25 pages
Muhammad Yasoob Ullah Khalid - Practical Python Projects-Muhammad Yasoob Ullah Khalid (2021)
PDF
100% (3)
Muhammad Yasoob Ullah Khalid - Practical Python Projects-Muhammad Yasoob Ullah Khalid (2021)
329 pages
ReferenceManual Astah UML Professional
PDF
No ratings yet
ReferenceManual Astah UML Professional
417 pages
Flask Python
PDF
No ratings yet
Flask Python
324 pages
Microservices With Docker, Flask, and React
PDF
No ratings yet
Microservices With Docker, Flask, and React
2 pages
Esources: Python Python Modules SQL
PDF
No ratings yet
Esources: Python Python Modules SQL
5 pages
Flask Tutorial 2
PDF
0% (1)
Flask Tutorial 2
15 pages
Flask
PDF
No ratings yet
Flask
284 pages
Flask Restplus
PDF
No ratings yet
Flask Restplus
86 pages
Learning Flask Framework - Sample Chapter
PDF
100% (2)
Learning Flask Framework - Sample Chapter
27 pages
Deploy Web Apps With Docker
PDF
No ratings yet
Deploy Web Apps With Docker
61 pages
Api-Demo: Platform-As-A-Service (Paas) Based Solution
PDF
No ratings yet
Api-Demo: Platform-As-A-Service (Paas) Based Solution
6 pages
Flask Docs
PDF
100% (1)
Flask Docs
300 pages