Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- CHOO SANGBUEM
- 71675619
- Added @app.route('/derek')
- which loads templates/sample.html
- """
- from flask import Flask, request, render_template
- def do_the_login(username, password):
- return "logging in user: %s, pass: %s" % (username, password)
- def show_the_login_form():
- return "show the login form"
- app = Flask(__name__)
- @app.route('/')
- def index():
- return 'Index Page'
- @app.route('/hello')
- def hello():
- return 'Hello, World'
- @app.route('/user/<username>')
- def show_user_profile(username):
- # show the user profile for that user
- return 'User %s' % username
- #int is the type and
- @app.route('/post/<int:post_id>')
- def show_post(post_id):
- # show the post with the given id, the id is an integer
- return 'Post %d' % post_id
- @app.route('/path/<path:subpath>')
- def show_subpath(subpath):
- # show the subpath after /path/
- return 'Subpath %s' % subpath
- @app.route('/projects/')
- def projects():
- return 'The project page'
- @app.route('/login', methods=['GET','POST'])
- def login():
- if request.method == 'POST':
- return do_the_login(request.form['username'], request.form['password'])
- else:
- return show_the_login_form()
- @app.route('/hi/')
- @app.route('/hi/<name>') #go to the url and add these at the end.
- def hi(name=None):
- return render_template('hello.html', name=name)
- @app.route('/derek') #go to the url and add these at the end.
- def derek():
- return render_template('sample.html')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement