Output questions
- Create a flask app that says "G'DAY MATE!" on launch in browser
- Create an app that renders this result to html, using a Python loop for the countdown:
ready to takeoff 10 9 8 7 6 5 4 3 2 1 blastoff
- create this pattern in html using Flask and a Python loop. Extension: make this scalable using a var in code:
* * * * * * * * *
- define a function processArray() that processes a list of 4 elements and writes them to html in reverse order:
value: 7 value: 3 value: 3 value: 1
Solutions
blastoff
from flask import *
app = Flask(__name__)
@app.route("/")
def go():
markup = "ready to takeoff<br>"
count = 10
while (count >= 1):
markup = markup + str(count) + "<br>"
count = count - 1
markup = markup + "blastoff"
return markup
app.run(debug=True)
process array
from flask import *
app = Flask(__name__)
myarray = [1,3,3,7]
markup = ""
@app.route("/")
def go():
processArray()
return markup
def processArray():
global markup
markup = ""
for stuff in reversed(myarray):
markup = markup + "value: " + str(stuff) + "<br>"
app.run(debug=True)