Created
March 29, 2016 22:24
-
-
Save abdelhai/7e99b87dc2d4dd6d059dfc10b14737db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# # A very simple Flask Hello World app for you to get started with... | |
# from flask import Flask | |
# app = Flask(__name__) | |
from flask import Flask, request | |
import json | |
import sys | |
from io import StringIO | |
app = Flask(__name__) | |
@app.route('/') | |
def hello_world(): | |
return 'Hello from Flask4!' | |
@app.route('/message', methods=['POST']) | |
def chat_message(): | |
old_stdout = sys.stdout | |
sys.stdout = strstdout = StringIO() | |
if 'thx' in request.form.get('text'): | |
print('u r welcome') | |
else: | |
blacklist = ['app', '__', 'flask', 'import', 'join', 'blacklist', | |
'globals', 'locals', 'truncate', 'remove', 'eval', 'exec', '.py'] | |
msg = request.form.get('text').split('pypie gimme ')[1] | |
if not any(word in msg for word in blacklist): | |
exec('print (' + msg + ')') | |
else: | |
print('sorry, no `' + msg + '` for u') | |
return json.dumps({'text': strstdout.getvalue().strip('\n')}) | |
#return json.dumps({'text': 'zzzzzz'}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment