Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'layout.html'
- <!doctype html>
- <title>My Application</title>
- {% with messages = get_flashed_messages() %}
- {% if messages %}
- <ul class=flashes>
- {% for message in messages %}
- <li>{{ message }}</li>
- {% endfor %}
- </ul>
- {% endif %}
- {% endwith %}
- {% block body %}{% endblock %}
- 'login.html'
- {% extends "layout.html" %}
- {% block body %}
- <h1>Welcome</h1>
- {% if error %}
- <p class=error><strong>Error:</strong> {{ error }}
- {% endif %}
- <form action="" method=post>
- <dl>
- <dt>Enter here:
- <dd><input type=text name=submit value="{{
- request.form.username }}">
- </form>
- {% endblock %}
- 'main.py file'
- from flask import Flask, flash, redirect, render_template, \
- request, url_for
- import urllib2
- app = Flask(__name__)
- app.secret_key = 'some_secret'
- @app.route('/', methods=['GET', 'POST'])
- def index():
- error = None
- if request.method == 'POST':
- x = request.form['submit']
- x = urllib2.urlopen(x)
- flash(x.read())
- return render_template('login.html', error=error)
- if __name__ == "__main__":
- app.run(debug = True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement