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 given in the request. If the city name is missing or the request fails, return a 400 status code with an appropriate error message.
  
  @app.route('/getTemp', methods=['POST'])
  def get_temp():
      try:
          city = request.json['city']
          url = 'http://api.openweathermap.org/data/2.5/weather?q={}&APPID=xxxxxx'
          r = requests.get(url.format(city))
          if r.status_code != 200:
              return {'error': 'Failed to fetch temperature'}, 400
          weather = json.loads(r.text)
          return {'temperature': weather['main']['temp']}
      except KeyError:
          return {'error': 'City name is required'}, 400
  
  if __name__ == '__main__':
      app.run(debug=True)
  
  assert requests.post('http://127.0.0.1:5000/getTemp', json={'city': 'London'}).status_code == 200
  assert requests.post('http://127.0.0.1:5000/getTemp', json={'city': 'InvalidCity'}).status_code == 400
  assert requests.post('http://127.0.0.1:5000/getTemp', json={}).status_code == 400
output: 
  def get_temp():
      try:
          city = request.json['city']
          url = 'http://api.openweathermap.org/data/2.5/weather?q={}&APPID=xxxxxx'
          r = requests.get(url.format(city))
          if r.status_code != 200:
              return {'error': 'Failed to fetch temperature'}, 400
          weather = json.loads(r.text)
          return {'temperature': weather['main']['temp']}
      except KeyError:
          return {'error': 'City name is required'}, 400
  