Advertisement
Guest User

admin

a guest
Oct 9th, 2022
1,104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 1 1
  1. @app.route('/admin', methods=["GET","POST"])
  2. @login_required
  3. def admin():
  4. if current_user.is_authenticated and current_user.is_admin:
  5. notes = ['campaign.txt', 'player1.txt', 'player2.txt']
  6.  
  7.  
  8. selected_note = 'campaign.txt'
  9. if request.method == 'POST' and request.form.get('note'):
  10. selected_note = request.form.get('note')
  11.  
  12. path = os.path.join('notes', selected_note)
  13. path = remove_dot_slash_recursive(path)
  14. if allowed_path(path):
  15. try:
  16. file = open(path, 'r')
  17. note_content = file.readlines()
  18. except Exception as e:
  19. note_content = ['This note does not exist\n']
  20.  
  21. return render_template('admin.html', notes=notes, note_content=note_content, selected_note=selected_note)
  22. return redirect('troll')
  23. else:
  24. return 'You are not the master!:('
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement