Microservice Patterns and Best Practices by Vinicius Feitosa Pacheco
Author:Vinicius Feitosa Pacheco
Language: eng
Format: epub
Tags: COM051010 - COMPUTERS / Programming Languages / General, COM051240 - COMPUTERS / Software Development and Engineering / Systems Analysis and Design, COM060180 - COMPUTERS / Web / Web Services and APIs
Publisher: Packt
Published: 2018-01-30T07:21:36+00:00
Preparing the app to run
The app.py file has the responsibility to run any application. For this file, let's start declaring the imports necessary. Note that, in addition to Flask, we import the Blueprint with all our routes and the MongoEngine instance containing the declaration of our entity:
import os from flask import Flask from views import famous_newsfrom models import db
Now, we go on to instantiate Flask and pass the settings of the environments, the database instance, and the instance of the view routes, as follows:
# instantiate the app app = Flask(__name__) # set config app_settings = os.getenv('APP_SETTINGS') app.config.from_object(app_settings) db.init_app(app) # register blueprints app.register_blueprint(famous_news)
At the end of the file, we have a simple statement to perform Flask on port 5000:
if __name__ == '__main__': app.run(host='0.0.0.0', port=5000)
The file app.py consists of the following formatting:
import os from flask import Flask from views import famous_news from models import db # instantiate the app app = Flask(__name__) # set config app_settings = os.getenv('APP_SETTINGS') app.config.from_object(app_settings) db.init_app(app) # register blueprints app.register_blueprint(famous_news) if __name__ == '__main__': app.run(host='0.0.0.0', port=5000)
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8301)
Test-Driven Development with Java by Alan Mellor(6731)
Data Augmentation with Python by Duc Haba(6644)
Principles of Data Fabric by Sonia Mezzetta(6396)
Learn Blender Simulations the Right Way by Stephen Pearson(6295)
Microservices with Spring Boot 3 and Spring Cloud by Magnus Larsson(6167)
Hadoop in Practice by Alex Holmes(5959)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5807)
RPA Solution Architect's Handbook by Sachin Sahgal(5563)
Big Data Analysis with Python by Ivan Marin(5368)
The Infinite Retina by Robert Scoble Irena Cronin(5253)
Life 3.0: Being Human in the Age of Artificial Intelligence by Tegmark Max(5148)
Pretrain Vision and Large Language Models in Python by Emily Webber(4331)
Infrastructure as Code for Beginners by Russ McKendrick(4092)
Functional Programming in JavaScript by Mantyla Dan(4038)
The Age of Surveillance Capitalism by Shoshana Zuboff(3955)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3806)
Embracing Microservices Design by Ovais Mehboob Ahmed Khan Nabil Siddiqui and Timothy Oleson(3610)
Applied Machine Learning for Healthcare and Life Sciences Using AWS by Ujjwal Ratan(3581)
