SHARE
TWEET

stupid-adblock-test

DeaD_EyE Nov 3rd, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2. from pathlib import Path
  3. from flask import Flask
  4. from flask import render_template
  5. from flask import session
  6. from flask import abort
  7. from flask import Response
  8.  
  9.  
  10. app = Flask(__name__)
  11. app.secret_key = os.urandom(20)
  12. INFO = Path('info.txt').read_text()
  13. RED = Path('red.jpg').read_bytes()
  14.  
  15. @app.route('/adblock-test/')
  16. @app.route('/adblock-test')
  17. def idx():
  18.     return render_template('index.html')
  19.  
  20. @app.route('/adblock-test/info.txt')
  21. def info():
  22.     if session.get('ad_loaded'):
  23.         return INFO
  24.     else:
  25.         abort(404, 'Bitte erst die Werbung laden, dann geht es weiter.')
  26.  
  27.  
  28. @app.route('/adblock-test/red.jpg')
  29. def ad():
  30.     session['ad_loaded'] = True
  31.     return Response(RED, mimetype='image/jpg')
  32.  
  33.  
  34.  
  35. if __name__ == '__main__':
  36.     app.run(port=5001)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top