Skip to content

Instantly share code, notes, and snippets.

@thanoskoutr
Created April 23, 2021 22:10
Show Gist options
  • Save thanoskoutr/cb32b6c2a2b23418ad45f65a6f1318a9 to your computer and use it in GitHub Desktop.
Save thanoskoutr/cb32b6c2a2b23418ad45f65a6f1318a9 to your computer and use it in GitHub Desktop.
A simple flask app with two endpoints to check the multithread performance of flask.
from flask import Flask, request, jsonify
from math import sqrt
app = Flask(__name__)
def successResponse():
return jsonify(success=True)
@app.route('/', methods=['POST', 'GET'])
def root():
return successResponse()
@app.route('/fast', methods=['POST', 'GET'])
def fast():
if request.method == 'GET':
return successResponse()
@app.route('/slow', methods=['POST', 'GET'])
def slow():
if request.method == 'GET':
for i in range(0, 10000):
res = i ** i
return successResponse()
if __name__ == '__main__':
app.run(port=5000, debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment