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: labs/coding-102-rest-python-ga/6.md
+10-10Lines changed: 10 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Step 6. Build Network Topology and Graphically Display it
1
+
# Step 6. Build Network Topology and Graphical Display
2
2
3
3
In this step we're going to get the network topology data and have a separate graphical tool Cisco [NeXt UI](https://developer.cisco.com/site/neXt/) parse the data and graphically render the topology. We'll also use a web server tool called [Flask](http://flask.pocoo.org/) which well use to interface with NeXt UI. Flask is a Python module
4
4
@@ -101,23 +101,23 @@ if __name__ == "__main__":
101
101
102
102
Let's look at what the code is doing. We'll focus on the key code changes.
103
103
**from flask import Flask*
104
-
* From the flask python module imports the Flask object
104
+
* From the flask python module imports the Flask object
105
105
**from flask import render_template, jsonify*
106
106
* From the flask python module imports a couple of functions which are render_template and jsonify.
107
107
**app = Flask(__name__)*
108
108
* Instanitates the Flask web application.
109
109
**@app.route("/")*
110
110
* Tags the function below it "def index()" and specifies that it is called as the default web page for the Flask web application variable 'app'.
111
111
**def index():*
112
-
* The index function that calls the Flask function render_template that loads the topology.html web page.
112
+
* The index function that calls the Flask function render_template that loads the topology.html web page.
113
113
**@app.route("/api/topology")*
114
-
* Tags the function below it "def topology()" and is called by NeXt UI. Identifies as web page for the Flask web application variable 'app'
114
+
* Tags the function below it "def topology()" and is called by NeXt UI. Identifies as web page for the Flask web application variable 'app'
115
115
**def topology():*
116
-
* Returns the network topology data in JSON format.
116
+
* Returns the network topology data in JSON format.
117
117
**if __name__ == "__main__":*
118
-
* Optional code that specifies that if this module is run, rather than just importing it and calling it's functions, that below this point is where the script should begin running. Python typically knows already has this information, but this prevents any ambiguity.
118
+
* Optional code that specifies that if this module is run, rather than just importing it and calling it's functions, that below this point is where the script should begin running. Python typically knows already has this information, but this prevents any ambiguity.
119
119
**app.run()*
120
-
* Starts the Flask web application.
120
+
* Starts the Flask web application.
121
121
122
122
123
123
To run this code sample:
@@ -131,15 +131,15 @@ To run this code sample:
131
131
4. Type the python command and then the filename at the command prompt, and press the return key.
132
132
**On Windows type*: **py -3 build-topology-web-server.py**. Or type: **python build-topology-web-server.py**
133
133
**On Mac OS or Linux type*: **python3 build-topology-web-server.py**
134
-
5. The program will start listening at IP 128.0.0.1 port 5000. If the error: *"ImportError: No module named 'flask'"* is given click on "How to Set up Your Computer" on the top of this web page.
134
+
5. The Flask web server will start listening at IP 127.0.0.1 port 5000. If the error: *"ImportError: No module named 'flask'"* is given click on *"How to Set up Your Computer"* on the top of this web page.
6. Open a web browser such as Chrome or Safari and in the URL field enter the URL **http://127.0.0.1:5000** . You should see a result like the following below.
* Compare the first three layers of the topology to what you drew in step 5. Do they match?
142
-
* Go to the templates directory and open the file topology.html. In the javascript block identified within block *<scripttype="text/javascript">* change the width and height from 800 to 400. Rerun the program. What's changed?
142
+
* Go to the templates directory and open the file topology.html. In the javascript block identified within block *<script type=text/javascript>* change the width and height from 800 to 400. Rerun the program. What's changed?
0 commit comments