SHARE
TWEET

Untitled

a guest May 22nd, 2019 613 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. import os
  3. from flask import Flask, request
  4.  
  5. app = Flask(__name__)
  6. ADMIN_TOKEN = "1064aeb6c01fbd0b8c52b44988c258b4"
  7.  
  8.  
  9. class File(object):
  10.     def __init__(self, name):
  11.         self.name = name
  12.  
  13.     def __repr__(self):
  14.         if ".." in self.name:
  15.             return "You are not allowed to read this file"
  16.         if not os.path.isfile(self.name):
  17.             return "File not found"
  18.         return open(self.name).read()
  19.  
  20.  
  21. @app.route("/")
  22. def index():
  23.     filename = request.args.get("filename", "")
  24.     template = "Filename " + filename + "<br><textarea>{0}</textarea>"
  25.     return template.format(File("./tpl/" + filename))
  26.  
  27. if __name__ == "__main__":
  28.     app.run()
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