External Exam Download Resources Web Applications Games Recycle Bin

output

simplemarkup.py

from flask import *
app = Flask(__name__)

@app.route("/")
def main():
    return "<h1>Hello Markup!</h1>"
 
app.run(debug=True)

multipleroutes.py

from flask import *
app = Flask(__name__)

@app.route("/")
@app.route("/home")
def main():
    return "Home page."
 
app.run(debug=True)

coinflip.py

from flask import *
import random

app = Flask(__name__)

#Browser refresh to change coin image!

@app.route("/")
def main():
  coinFace = flip(random.randint(1, 2))
  return "<img src='"+coinFace+"'>"

def flip(x):
  if(x==1):
    return "https://digisoln.com/resources/coins/heads.png"
  else:
    return "https://digisoln.com/resources/coins/tails.png"

app.run(debug=True)