Skip to content

Commit 1a8dc8f

Browse files
committed
changes
1 parent 88a8457 commit 1a8dc8f

File tree

1 file changed

+10
-10
lines changed
  • labs/coding-102-rest-python-ga

1 file changed

+10
-10
lines changed

labs/coding-102-rest-python-ga/6.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff 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
22

33
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
44

@@ -101,23 +101,23 @@ if __name__ == "__main__":
101101

102102
Let's look at what the code is doing. We'll focus on the key code changes.
103103
* *from flask import Flask*
104-
* From the flask python module imports the Flask object
104+
* From the flask python module imports the Flask object
105105
* *from flask import render_template, jsonify*
106106
* From the flask python module imports a couple of functions which are render_template and jsonify.
107107
* *app = Flask(__name__)*
108108
* Instanitates the Flask web application.
109109
* *@app.route("/")*
110110
* 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'.
111111
* *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.
113113
* *@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'
115115
* *def topology():*
116-
* Returns the network topology data in JSON format.
116+
* Returns the network topology data in JSON format.
117117
* *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.
119119
* *app.run()*
120-
* Starts the Flask web application.
120+
* Starts the Flask web application.
121121

122122

123123
To run this code sample:
@@ -131,15 +131,15 @@ To run this code sample:
131131
4. Type the python command and then the filename at the command prompt, and press the return key.
132132
* *On Windows type*: **py -3 build-topology-web-server.py**. Or type: **python build-topology-web-server.py**
133133
* *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.
135135
![](/posts/files/coding-102-rest-python-ga/assets/images/webapp-start.png)
136136
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.
137137
![](/posts/files/coding-102-rest-python-ga/assets/images/topology-graph.png)
138138

139139

140140
## Things to Try
141141
* 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 *<script type="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 * &lt; script type=text/javascript &gt; * change the width and height from 800 to 400. Rerun the program. What's changed?
143143

144144

145-
##Congratulations! You've completed Coding 102!
145+
### Congratulations! You've completed Coding 102!

0 commit comments

Comments
 (0)