Lecture code examples from Week 13, should be runnable on your own computer with Python and Flask installed. Save this file as week13.py # To run: python week13.py # http://flask.pocoo.org/docs/0.10/quickstart/#quickstart from flask import Flask, render_template, jsonify app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" @app.route('/user/') def show_user_profile(username): return render_template('profile.html', name=username) @app.route("/lotsofdata") def people(): my_people = {'Alice': 25, 'Bob': 21, 'Charlie': 20, 'Doug': 28} return jsonify(my_people) if __name__ == "__main__": app.run(debug=True) # debug=True means auto-reload on change Save this file as templates/profile.html (VERY important to create a template/ sub-directory!) {% if name %}

Hello, {{ name }}!

{% else %}

Hello noname!

{% endif %}