1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| from flask import Flask, request, render_template_string import socket import threading import html
app = Flask(__name__)
@app.route('/', methods=["GET"]) def source(): with open(__file__, 'r', encoding='utf-8') as f: return '<pre>'+html.escape(f.read())+'</pre>'
@app.route('/', methods=["POST"]) def template(): template_code = request.form.get("code") blacklist = ['__', 'import', 'os', 'sys', 'eval', 'subprocess', 'popen', 'system', '\r', '\n'] for black in blacklist: if black in template_code: return "Forbidden content detected!" result = render_template_string(template_code) print(result) return result if __name__ == "__main__": app.run(host='127.0.0.1',port=5000)
|