Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @app.route('/')
- def index():
- if 'username' in session:
- return 'Logged in as %s' % escape(session['username'])
- return 'You are not logged in'
- @app.route('/login', methods=['GET', 'POST'])
- def login():
- if request.method == 'POST':
- username = request.form['username']
- password = request.form['password']
- if authenticate(str(username), str(password)):
- session['username'] = request.form['username']
- return redirect(url_for('index'))
- else:
- return 'Invalid username/password'
- return render_template('login.html')
- @app.route('/logout')
- def logout():
- # remove the username from the session if it's there
- session.pop('username', None)
- return redirect(url_for('index'))
- {% extends "layout.html" %}
- {% block body %}
- {% if error %}<p class="error"><strong>Error:</strong> {{ error }}{% endif %}
- <form action="{{ url_for('login') }}" method="post">
- <div class="wrap">
- <div class="rpi-logo">
- <img src="static/images/Raspi-PGB001.png">
- </div>
- <input type="text" placeholder="username" name="username" required>
- <div class="bar">
- <i></i>
- </div>
- <input type="password" placeholder="password" name="password" required>
- <button>Sign in</button>
- </div>
- </form>
- {% endblock %}
- <!doctype html>
- <title>Web APi</title>
- <link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}">
- <div class=page>
- {% for message in get_flashed_messages() %}
- <div class=flash>{{ message }}</div>
- {% endfor %}
- {% block body %}{% endblock %}
- </div>
- {% extends "layout.html" %}
- {% block body %}
- <div>INDEX.HTML</div>
- {% if error %}<p class="error"><strong>Error:</strong> {{ error }}{% endif %}
- <form action="{{ url_for('preview') }}" method="post">
- <div class="wrap">
- <div class="rpi-logo">
- <img src="static/images/Raspi-PGB001.png">
- </div>
- <button>Start Preview</button>
- </div>
- </form>
- {% endblock %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement