input: Write a function to optimize a Flask application for efficient performance. The function should include recommendations for using Redis for caching, uWSGI and gunicorn as WSGI servers, Flask-Compress for compression, and global variables where applicable. Additionally, it should advise against using SQL queries directly and suggest using query parameters in URLs and thread-local objects for performance.
  
  
  assert optimize_flask_app=='''from flask import Flask, request, jsonify
  
  app = Flask(__name__)
  
  @app.route('/api/<endpoint>', methods=['GET', 'POST'])
  def process_request(endpoint):
      # Performance optimization
      # Use Redis for caching session and query performance
      # Use uWSGI for Python applications
      # Use gunicorn as WSGI server
      # Use Flask-Compress extension for compression
      # Use global variables where applicable
      # Don't use sql queries directly, always use model methods
      # Use query parameter in URLs instead of plain parameters
      # Use thread-local objects for performance
  
      # Your code here
  '''
  
output: 
  from flask import Flask, request, jsonify
  import redis
  from flask_compress import Compress
  
  app = Flask(__name__)
  Compress(app)
  
  # Use Redis for caching
  redis_cache = redis.StrictRedis(host='localhost', port=6379, db=0)
  
  # Global variable for performance
  global_data = {}
  
  @app.route('/api/<endpoint>', methods=['GET', 'POST'])
  def process_request(endpoint):
      # Use query parameters in URLs
      query_params = request.args
      
      # Use Redis for caching
      cached_data = redis_cache.get(endpoint)
      if cached_data:
          return jsonify(cached_data)
      
      # Use global variables where applicable
      if endpoint in global_data:
          return jsonify(global_data[endpoint])
      
      # Don't use SQL queries directly, always use model methods
      # Example: data = Model.get_data(query_params)
      
      # Use thread-local objects for performance
      # Example: thread_local_data = get_thread_local_data()
      
      # Process the request and store in cache
      # Example: result = process_data(query_params)
      # redis_cache.set(endpoint, result)
      # global_data[endpoint] = result
      
      return jsonify(result)
  