Created
June 4, 2019 14:34
-
-
Save libbkmz/b580215db3c005d81c7af0e358cd5354 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import requests as req | |
import concurrent.futures as cf | |
import string | |
import random | |
WORKERS = 32 | |
random_str = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(128)) | |
def worker(): | |
while True: | |
_ = req.put( | |
"http://127.0.0.1:9999/not_found_url", | |
data=random_str, | |
headers={ | |
"Content-Type": "application/json", | |
}) | |
if __name__ == "__main__": | |
executor = cf.ThreadPoolExecutor(max_workers=WORKERS) | |
fs = [] | |
for _ in range(WORKERS): | |
fs.append( | |
executor.submit(worker) | |
) | |
for f in cf.as_completed(fs): | |
print (f.result()) |
This file contains hidden or 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
from flask import Flask, request | |
app = Flask(__name__) | |
@app.route("/", methods=["PUT"]) | |
def hello(): | |
_ = (request.data) | |
return "Hello World!" | |
if __name__ == "__main__": | |
app.run(host='127.0.0.1', port=9999, debug=False, threaded=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
python2:
pip install flask requests futures