input: Write a function to design a web server in Python using the Flask framework that serves a JSON object containing the current temperature for a city based on the city name provided in the request. The function should initialize a Flask app, define a route for retrieving the temperature, and return the temperature in the JSON format. If the city name is not provided or the weather API returns an error, the function should return an appropriate error message.
  assert get_temp('London') == {'temperature': 280.32}
  assert get_temp('New York') == {'temperature': 279.01}
  assert get_temp('UnknownCity') == {'error': 'City not found'}
  assert get_temp('') == {'error': 'City name not provided'}
  assert get_temp(None) == {'error': 'Invalid request'}
output: from flask import Flask, request, jsonify
  import requests
  
  app = Flask(__name__)
  
  @app.route('/get_temp', methods=['GET'])
  def get_temp():
      city = request.args.get('city')
      if not city:
          return jsonify({'error': 'City name not provided'}), 400
      
      weather_api_url = f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid=YOUR_API_KEY"
      
      try:
          response = requests.get(weather_api_url)
          response.raise_for_status()
          weather_data = response.json()
          if weather_data.get('cod') != 200:
              return jsonify({'error': 'City not found'}), 404
          temperature = weather_data['main']['temp']
          return jsonify({'temperature': temperature})
      except requests.exceptions.RequestException:
          return jsonify({'error': 'Invalid request'}), 400