<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: NIBRAS NAZAR</title>
    <description>The latest articles on DEV Community by NIBRAS NAZAR (@nibrasnazar).</description>
    <link>https://dev.to/nibrasnazar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F417997%2Fb8955cda-7f59-4ac8-9bb7-15340463a2cd.jpeg</url>
      <title>DEV Community: NIBRAS NAZAR</title>
      <link>https://dev.to/nibrasnazar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nibrasnazar"/>
    <language>en</language>
    <item>
      <title>Live Location (Flutter + Google Map)</title>
      <dc:creator>NIBRAS NAZAR</dc:creator>
      <pubDate>Fri, 29 May 2020 09:55:16 +0000</pubDate>
      <link>https://dev.to/innovationincu/live-location-flutter-google-map-55d4</link>
      <guid>https://dev.to/innovationincu/live-location-flutter-google-map-55d4</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rB97o8b7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AvPV4p633KBi90VWAgiqCDA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rB97o8b7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AvPV4p633KBi90VWAgiqCDA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Integrating Google Map
&lt;/h4&gt;

&lt;p&gt;To get started we need to first add Google Maps in our flutter application. This is done with the help of a Flutter plugin google_maps_flutter for integrating Google Maps in iOS and Android applications.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add google_maps_flutter as a dependency in your pubspec.yaml file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fzam3Ae---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/418/1%2AKdzbn1xo2OqS-BK09V9Ssw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fzam3Ae---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/418/1%2AKdzbn1xo2OqS-BK09V9Ssw.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Get an API key at &lt;a href="https://cloud.google.com/maps-platform/"&gt;https://cloud.google.com/maps-platform/&lt;/a&gt; and enable Google Map SDK. find detailed steps &lt;a href="https://developers.google.com/maps/gmp-get-started"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Specify your API key in the application manifest android/app/src/main/AndroidManifest.xml
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;manifest ...
  &amp;lt;application ...
    &amp;lt;meta-data android:name="com.google.android.geo.API\_KEY"
               android:value="YOUR API KEY"/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;import the package and you can now add a GoogleMap widget to your widget tree.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**import**'package:google\_maps\_flutter/google\_maps\_flutter.dart';

**void** main() =&amp;gt; runApp(MyApp());

**class**  **MyApp**  **extends**  **StatelessWidget** {
**@override**
  Widget build(BuildContext context) {
**return** MaterialApp(
      title: 'Demo',
      home: MapSample(),
    );
  }
}

class MapSample extends StatefulWidget {
@override
\_MapSampleState createState() =&amp;gt; \_MapSampleState();
}

class \_MapSampleState extends State&amp;lt;MapSample&amp;gt; {

GoogleMapController mapController;

LatLng \_initialPosition = LatLng(37.42796133588664, -122.885740655967);

void \_onMapCreated(GoogleMapController \_cntrl) async {
mapController = await \_cntrl;
}

return Scaffold(
  appBar: AppBar(
  backgroundColor: Color(0xff2758a1),
  title: Text('Demo'),
  ),
  body: Stack(
    children: &amp;lt;Widget&amp;gt;[
    GoogleMap(
      initialCameraPosition: CameraPosition(target: \_initialPosition, zoom: 10),
      mapType: MapType.normal,
      onMapCreated: \_onMapCreated,
      myLocationEnabled: true,
      myLocationButtonEnabled: true,
      zoomControlsEnabled: false,
      )
     ],
   ),
 );
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Implementing live location
&lt;/h4&gt;

&lt;p&gt;To implement live location we need to add Flutter Location Plugin . It's a Flutter plugin to easily handle a realtime location in iOS and Android.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add Flutter Location Pluginas a dependency in your file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cjJYaunj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/378/1%2AEkOtd2iYOiOOilxunBQRDg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cjJYaunj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/378/1%2AEkOtd2iYOiOOilxunBQRDg.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;import the package with
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**import**'package:location/location.dart';
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;now we will make use of a listener to get continuous callbacks whenever the device position is changing.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Location location = **new** Location();

location.onLocationChanged.listen((LocationData currentLocation) {
_// Use current location_
});
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;now let’s add this listener on our _onMapCreated Function with the functionality to animate the camera to each change in the device position.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void \_onMapCreated(GoogleMapController \_cntrl) async {

mapController = await \_cntrl;

locationSubscription = \_location.onLocationChanged.listen((l) {
  mapController.animateCamera(
    CameraUpdate.newCameraPosition(
      CameraPosition(target: LatLng(l.latitude, l.longitude),zoom: 18)),

);

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Final code
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**void** mai() =&amp;gt; runApp(MyApp());

**class**  **MyApp**  **extends**  **StatelessWidget** {
**@override**
  Widget build(BuildContext context) {
**return** MaterialApp(
      title: 'Demo',
      home: MapSample(),
    );
  }
}

class MapSample extends StatefulWidget {
@override
\_MapSampleState createState() =&amp;gt; \_MapSampleState();
}

class \_MapSampleState extends State&amp;lt;MapSample&amp;gt; {

GoogleMapController mapController;
Location location = **new** Location();

LatLng \_initialPosition = LatLng(37.42796133588664, -122.885740655967);

void \_onMapCreated(GoogleMapController \_cntrl) async {

mapController = await \_cntrl;

locationSubscription = \_location.onLocationChanged.listen((l) {
  mapController.animateCamera(
    CameraUpdate.newCameraPosition(
      CameraPosition(target: LatLng(l.latitude, l.longitude),zoom: 18)),

);

}

return Scaffold(
  appBar: AppBar(
  backgroundColor: Color(0xff2758a1),
  title: Text('Demo'),
  ),
  body: Stack(
    children: &amp;lt;Widget&amp;gt;[
    GoogleMap(
      initialCameraPosition: CameraPosition(target: \_initialPosition, zoom: 10),
      mapType: MapType.normal,
      onMapCreated: \_onMapCreated,
      myLocationEnabled: true,
      myLocationButtonEnabled: true,
      zoomControlsEnabled: false,
      )
     ],
   ),
 );
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  Reference
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Google Map plugin:&lt;/strong&gt; &lt;a href="https://pub.dev/packages/google_maps_flutter"&gt;https://pub.dev/packages/google_maps_flutter&lt;/a&gt; &lt;strong&gt;location plugin:&lt;/strong&gt; &lt;a href="https://pub.dev/packages/location"&gt;https://pub.dev/packages/location&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enjoy Coding ……………!&lt;/strong&gt;&lt;/p&gt;




</description>
      <category>livelocation</category>
      <category>googlemaps</category>
      <category>flutter</category>
    </item>
    <item>
      <title>Android Wireless Debugging (Flutter + MAC + VsCode)</title>
      <dc:creator>NIBRAS NAZAR</dc:creator>
      <pubDate>Fri, 08 May 2020 13:23:27 +0000</pubDate>
      <link>https://dev.to/innovationincu/android-wireless-debugging-flutter-mac-vscode-28jn</link>
      <guid>https://dev.to/innovationincu/android-wireless-debugging-flutter-mac-vscode-28jn</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2E4G1rYn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ABxX2fvhmNvpj21i13nlC4w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2E4G1rYn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ABxX2fvhmNvpj21i13nlC4w.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This article is purely for Mac Users who develop flutter apps in MacBook with VScode.&lt;/p&gt;

&lt;p&gt;Follow the steps below to get done.&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 1: Install ADB
&lt;/h4&gt;

&lt;p&gt;ADB stands for “Android Debug Bridge,” and it is a command-line tool that is used to communicate with a smartphone, tablet, smartwatch, set-top box, or any other device that can run the Android operating system (even an emulator). The computer with ADB can send commands to our device through the USB cable and wirelessly for debugging&lt;/p&gt;

&lt;p&gt;the easiest way to install ADB is&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install homebrew
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ruby -e "$(curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/master/install](https://raw.githubusercontent.com/Homebrew/install/master/install))"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Install ADB
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew cask install android-platform-tools
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;run adb --versioncommand in terminal to ensure ADB has been installed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5Frhyvlg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/637/1%2ANYq7RM0bjwVxCFlET7LQBA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5Frhyvlg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/637/1%2ANYq7RM0bjwVxCFlET7LQBA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 2: Install ADB interface for VScode
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Search for ADB interface in the Extensions of VScode&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JRJXtHVv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/976/1%2AjlUuuAI4CMiNPEOGJJPR1Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JRJXtHVv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/976/1%2AjlUuuAI4CMiNPEOGJJPR1Q.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select the above Extension and install&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Step 3: Wireless debugging
&lt;/h4&gt;

&lt;p&gt;Before we start wireless debugging make sure that your android phone is in developer mode and “debugging” and “wireless debugging” options are toggled on.&lt;/p&gt;

&lt;p&gt;Also, both the computer and android device must be connected to the same WiFi.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---1jGMbZf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AnPmzgLIqFr1NyGsnmltJUQ.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---1jGMbZf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AnPmzgLIqFr1NyGsnmltJUQ.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now follow the steps given below…&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open VScode&lt;/li&gt;
&lt;li&gt;Connect an Android device to the computer using a USB cable&lt;/li&gt;
&lt;li&gt;Open Command Palette ( command + shift + P)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cqfcj7ry--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1017/1%2A_YM-gl4nIC03gCt0VoowZg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cqfcj7ry--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1017/1%2A_YM-gl4nIC03gCt0VoowZg.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Select the commands given below from the command palette&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;‘&lt;em&gt;ADB: Disconnect from any device’&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;‘ADB: Reset connected devices port to:5555&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Now disconnect the Android device from the computer and Select the command below from the Command Palette&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;‘ADB: Connect to device IP’&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Enter the IP address of the Android device when prompted&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--952a5Tcz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1015/1%2A0lJmTIJAGZe5ADY97hLCYQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--952a5Tcz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1015/1%2A0lJmTIJAGZe5ADY97hLCYQ.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(you can find the IP address of the android device from its *settings&amp;gt;status )&lt;/p&gt;

&lt;p&gt;You may have to wait for a while to start.&lt;/p&gt;

&lt;h4&gt;
  
  
  Enjoy Android wireless debugging……………
&lt;/h4&gt;




</description>
      <category>mac</category>
      <category>androiddebugbridge</category>
      <category>vscode</category>
      <category>flutter</category>
    </item>
    <item>
      <title>Flask: Before and After request Decorators</title>
      <dc:creator>NIBRAS NAZAR</dc:creator>
      <pubDate>Thu, 30 Apr 2020 12:53:40 +0000</pubDate>
      <link>https://dev.to/innovationincu/flask-before-and-after-request-decorators-5320</link>
      <guid>https://dev.to/innovationincu/flask-before-and-after-request-decorators-5320</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--t75cZSCl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/640/1%2AO0S2-UBv_Y1RRgHgRkg1yQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--t75cZSCl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/640/1%2AO0S2-UBv_Y1RRgHgRkg1yQ.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In addition to static and dynamic routes to functions/views using the @app.route() decorator, Flask empowers us with several powerful decorators to supplement the routes we create with .route(). In this article, we will look at some ways to run functions before and after a request in Flask using the decorators&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;before_request&lt;/li&gt;
&lt;li&gt;after_request&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;before explaining those, let’s write a very basic flask application&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask

app = Flask(\_\_name\_\_)

@app.route("/")
def index():
    print("Index running!")

if \_\_name\_\_ == "\_\_main\_\_":
    app.run()
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So whenever a request to the root &lt;em&gt;(“/”)&lt;/em&gt; is made, we would see the output shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Index running!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We make use of before_request and after_requestIf we want any specific task to get executed before and after the request respectively.&lt;/p&gt;

&lt;h3&gt;
  
  
  before_request
&lt;/h3&gt;

&lt;p&gt;The before_request decorator allows us to execute a function before any request. i.e, the function defined with the .before_request() decorator will execute before every request is made.&lt;/p&gt;

&lt;p&gt;We can do this by decorating a function with @app.before_request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@app.before\_request
def before\_request\_func():
    print("before\_request executing!")
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;after adding this function, we get the following output whenever we try to make a request to the route (“/”).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;before\_request executing!
Index running!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;we can make use of this function in cases like :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Opening database connections.&lt;/li&gt;
&lt;li&gt;tracking user actions&lt;/li&gt;
&lt;li&gt;adding a “back button” feature by remembering the last page the user visited before loading the next&lt;/li&gt;
&lt;li&gt;determining user permissions, etc……&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;before_request are not required to return anything, however, If a before_request function returns a value, it will be considered as if it was the return value for the view and any further request handling is stopped.&lt;/p&gt;

&lt;h3&gt;
  
  
  after_request
&lt;/h3&gt;

&lt;p&gt;The after_request decorator works in the same way as before_request decorator, except, It allows us to execute a function after each request.&lt;/p&gt;

&lt;p&gt;let us see an example by adding this function to our application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@app.after\_request
def after\_request\_func(response):
    print("after\_request executing!")
    return response
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;by making a request to any route on our application we would see the following output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;before\_request executing!
Index running!
after\_request executing!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;after_request functions must take and return an instance of the Flask response class.&lt;/p&gt;

&lt;p&gt;this function can be used in cases like :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;close a database connection&lt;/li&gt;
&lt;li&gt;To alert the user with changes in the application, etc….&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Any functions decorated with after_request will NOT run if the application throws an exception.&lt;/p&gt;

&lt;h4&gt;
  
  
  Our application :
&lt;/h4&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from flask import Flask

app = Flask(\_\_name\_\_)

@app.before\_request
def before\_request\_func():
    print("before\_request executing!")

@app.after\_request
def after\_request\_func(response):
    print("after\_request executing!")
    return response

@app.route("/")
def index():
    print("Index running!")

if \_\_name\_\_ == "\_\_main\_\_":
    app.run()
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;for more you can visit the flask documentation page here &lt;a href="https://flask.palletsprojects.com/en/1.1.x/"&gt;https://flask.palletsprojects.com/en/1.1.x/&lt;/a&gt;&lt;/p&gt;




</description>
      <category>flask</category>
      <category>decorators</category>
      <category>python</category>
      <category>webdev</category>
    </item>
    <item>
      <title>JavaScript Execution Context</title>
      <dc:creator>NIBRAS NAZAR</dc:creator>
      <pubDate>Fri, 17 Apr 2020 12:13:15 +0000</pubDate>
      <link>https://dev.to/innovationincu/javascript-execution-context-4817</link>
      <guid>https://dev.to/innovationincu/javascript-execution-context-4817</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;‘JavaScript is the world’s most misunderstood programming language.’&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;- Douglas Crockford&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KjCoUlNf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/750/1%2Ad9FjsBsxNIniTalGh-H02A.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KjCoUlNf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/750/1%2Ad9FjsBsxNIniTalGh-H02A.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This article is for js beginners to understand the concept of order of execution. for that, we need to talk about &lt;strong&gt;Execution Contexts&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Prerequisite: knowledge about&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Objects&lt;/li&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Execution Contexts&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;All JavaScript code runs in an environment, and these environments are called &lt;strong&gt;Execution Contexts&lt;/strong&gt;. Imagine an Execution Context as a container or a simple box which stores variables, and in which a piece of our code is evaluated and executed. We can associate each Execution Context as an  &lt;strong&gt;Object&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zptqULsa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AmeXIkoJ1-DIxtibKcMeX1Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zptqULsa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AmeXIkoJ1-DIxtibKcMeX1Q.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Global Execution Context&lt;/strong&gt; is the default Execution Context in which all the code that is not inside of any function is executed. Global execution context is associated with the global object, in the case of a browser, it will be a window object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;firstName == window.firstName //true
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Each time a function is called, a new Execution Context( variables and statement to be executed of that function ) is created and stacked up in the &lt;strong&gt;Execution Stack&lt;/strong&gt;. An Execution Stack is the one that holds the Execution Contexts of the currently invoked functions.&lt;/p&gt;

&lt;p&gt;An active Execution Context is the one that is at the top of the Execution Stack.&lt;/p&gt;

&lt;p&gt;let’s see an example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var name = 'Ron';

function first(){
  var a = 'hello';
  second(); // calling fuction 'second()' 
  var x = a + name;
}

function second(){
  var b = 'hi';
  var y = b + name;
}

first(); // calling function 'first();'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---t3YFweF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AZpADOf6OdeLDm_yvA1W70A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---t3YFweF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AZpADOf6OdeLDm_yvA1W70A.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In the beginning, the Execution stack contains Global Execution Context. The variable ‘name’ and function declarations belong to this Global Execution Context.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZYGmvuYJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AiNn6pVJfr1xbOS1PCAUblA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZYGmvuYJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AiNn6pVJfr1xbOS1PCAUblA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When the function ‘first()’ is called, its Execution Context gets on to the top of the current Execution Context (global execution context ) and becomes the active execution context.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KPyyZ679--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AQXn2zRS5E51j8ab-0Gqg_w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KPyyZ679--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AQXn2zRS5E51j8ab-0Gqg_w.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Function ‘first’ then calls the ‘second()’ before completing its execution and execution context of ‘second’ becomes active.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZYGmvuYJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AiNn6pVJfr1xbOS1PCAUblA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZYGmvuYJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AiNn6pVJfr1xbOS1PCAUblA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When function ‘second’ finishes its execution, its Execution Context gets popped off from the Execution Stack and Execution Context of ‘first’ becomes active and continues with its remaining task.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---t3YFweF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AZpADOf6OdeLDm_yvA1W70A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---t3YFweF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AZpADOf6OdeLDm_yvA1W70A.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;similarly when function ‘first’ finishes its task, its execution context gets popped off from the stack.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As said before, Execution Context can be considered as an &lt;em&gt;object&lt;/em&gt; and this object has three properties:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9phbQNN6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A66cOPE4rb-zF-rOuFP29uw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9phbQNN6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2A66cOPE4rb-zF-rOuFP29uw.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Variable Object&lt;/li&gt;
&lt;li&gt;Scope Chain&lt;/li&gt;
&lt;li&gt;“This” Variable&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Variable Object &lt;/em&gt;&lt;/strong&gt; _— _which will contain function arguments in a variable declaration as well as function declarations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scope Chain &lt;/strong&gt; — contains the current variable objects as well as the variable objects of all its parents;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;“This” Variable&lt;/strong&gt;  — reference to the current Execution Context.&lt;/p&gt;

&lt;p&gt;When a function is called, a new execution context is put on top of the execution stack, and this happens in two phases:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Creation Phase&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Execution Phase&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Creation Phase&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The Creation Phase includes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;creation of the variable object ( VO ),&lt;/li&gt;
&lt;li&gt;creation of the scope chain,&lt;/li&gt;
&lt;li&gt;determines the value of “this” variable.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Creation of Variable Object ( VO ) :&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The argument object is created, which contains all the arguments that were passed into the function.&lt;/li&gt;
&lt;li&gt;The code is scanned for &lt;strong&gt;function declarations&lt;/strong&gt; , and for each function, a property is created in a variable object, &lt;strong&gt;pointing to that function&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;the code is scanned for &lt;strong&gt;variable declarations&lt;/strong&gt; , and for each variable, a property is created in a variable object and set to “ &lt;strong&gt;undefined&lt;/strong&gt; ”.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The last two points are called “ &lt;strong&gt;Hoisting&lt;/strong&gt; ”.Functions and variables are hoisted in JavaScript, which means that they are available before the execution phase actually starts.&lt;/p&gt;

&lt;p&gt;let's see an example….&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;calculateAge(1996); // function call

function calculateAge(year) { // function declaration
    console.log(2020 - year);
}

output : 
24
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The ‘calculateAge’ function is available to use it before the function declaration due to &lt;strong&gt;Hoisting.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creation of Scope Chain :&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Scope defines the access to a variable from a place&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Each function creates a scope:&lt;/strong&gt; space or an environment in which the variables that it defines are accessible.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lexical scoping:&lt;/strong&gt; a function that is lexically within another function gets access to a scope of the outer function.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;let’s see an example …&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var a = 'Hello!';
first();

function first() {
    var b = 'Hi!';
    second();

    function second() {
        var c = 'Hey!';
        console.log(a + b + c);
    }
}

output:
 Hello!Hi!Hey!
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here the function ‘second’ can access the global variables and variables from its parent function ‘first’.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T1iZdm2d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/866/1%2Ar5kk58Iex_esEswQbMj1qA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T1iZdm2d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/866/1%2Ar5kk58Iex_esEswQbMj1qA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the creation phase, each execution context object will get exact scope chain, which is basically all the variable objects ( VO )that an execution context has access to, because the variable object (VO) stores all the defined variables and functions. In this example, in the second scope, we have access to the variable object, of the second functions, of the first function, and to global variable object&lt;/p&gt;

&lt;p&gt;The global scope will never ever have access to the variables b or c unless we return the values from the functions. So locally scoped variables are not visible to their parent scopes.&lt;/p&gt;

&lt;p&gt;The execution stack is different from the scope chain. An Execution Stack is an order in which functions are called but the scope chain is the order in which functions are written in the code&lt;/p&gt;

&lt;p&gt;You can find the difference with the example given below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var a = 'Hello!';
first();

function first() {
    var b = 'Hi!';
    second();

function second() {
        var c = 'Hey!';
        third()
    }
}

function third() { //on top of execution stack
  var d = 'John';
  console.log(a+b+c+d); //here b and c not accessible by ScopeChain        
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Determining ‘this’ Variable :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;‘this’ variable is a variable that each and every Execution Context gets and points to an object&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In a &lt;strong&gt;Regular Function Call&lt;/strong&gt; , the ‘this’ keyword simply points at the global object (The window object. in the browser )&lt;/li&gt;
&lt;li&gt;In a &lt;strong&gt;method call&lt;/strong&gt; , ‘this’ variable points to the object that is calling the method.&lt;/li&gt;
&lt;li&gt;the ‘this’ keyword is not assigned a value until the function where it is defined is actually called.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;let’s see two examples here….&lt;/p&gt;

&lt;p&gt;example 1 :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;calculateAge(1985);

function calculateAge(year) {
    console.log(2020 - year);
    console.log(this); // output : window object{}
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;here ‘this’ Variable is the window object because it is a regular function call and object that the function ‘calculateAge’ is attached to is the global object.&lt;/p&gt;

&lt;p&gt;example 2 :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var john = {
    name: 'John',
    yearOfBirth: 1990,
    calculateAge: function() {
        console.log(this); // output : john object {}
        console.log(2016 - this.yearOfBirth);
    }
}

john.calculateAge();
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;here ‘this’ keyword refers to the object that called the method which is the john object. In method call, ‘this’ variable always points to the object that is calling the method.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Execution Phase&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;Execution phase&lt;/strong&gt; includes the execution of the code and the function that generated the current execution context.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;The End&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  One of the best course to learn JS: &lt;a href="https://www.udemy.com/share/101WfeAEMecFdRRnwD/"&gt;https://www.udemy.com/share/101WfeAEMecFdRRnwD/&lt;/a&gt;
&lt;/h4&gt;




</description>
      <category>programming</category>
      <category>javascript</category>
      <category>executioncontext</category>
      <category>coding</category>
    </item>
  </channel>
</rss>
