Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. @app.route('/')
  2. def index():
  3. if 'username' in session:
  4. return 'Logged in as %s' % escape(session['username'])
  5. return 'You are not logged in'
  6.  
  7. @app.route('/login', methods=['GET', 'POST'])
  8. def login():
  9. if request.method == 'POST':
  10. username = request.form['username']
  11. password = request.form['password']
  12. if authenticate(str(username), str(password)):
  13. session['username'] = request.form['username']
  14. return redirect(url_for('index'))
  15. else:
  16. return 'Invalid username/password'
  17. return render_template('login.html')
  18.  
  19. @app.route('/logout')
  20. def logout():
  21. # remove the username from the session if it's there
  22. session.pop('username', None)
  23. return redirect(url_for('index'))
  24.  
  25. {% extends "layout.html" %}
  26. {% block body %}
  27. {% if error %}<p class="error"><strong>Error:</strong> {{ error }}{% endif %}
  28. <form action="{{ url_for('login') }}" method="post">
  29. <div class="wrap">
  30. <div class="rpi-logo">
  31. <img src="static/images/Raspi-PGB001.png">
  32. </div>
  33. <input type="text" placeholder="username" name="username" required>
  34. <div class="bar">
  35. <i></i>
  36. </div>
  37. <input type="password" placeholder="password" name="password" required>
  38. <button>Sign in</button>
  39. </div>
  40. </form>
  41. {% endblock %}
  42.  
  43. <!doctype html>
  44. <title>Web APi</title>
  45. <link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}">
  46. <div class=page>
  47. {% for message in get_flashed_messages() %}
  48. <div class=flash>{{ message }}</div>
  49. {% endfor %}
  50. {% block body %}{% endblock %}
  51. </div>
  52.  
  53. {% extends "layout.html" %}
  54. {% block body %}
  55. <div>INDEX.HTML</div>
  56. {% if error %}<p class="error"><strong>Error:</strong> {{ error }}{% endif %}
  57. <form action="{{ url_for('preview') }}" method="post">
  58. <div class="wrap">
  59. <div class="rpi-logo">
  60. <img src="static/images/Raspi-PGB001.png">
  61. </div>
  62. <button>Start Preview</button>
  63. </div>
  64. </form>
  65. {% endblock %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement