input: Write a function to create a web server using the Flask framework that serves a JSON object containing the current temperature for a specified city. The city name should be provided in the request body. The server should make an API call to retrieve the temperature and return it in the response. If the city name is invalid or the API call fails, the function should return an appropriate error message.
  
  assert get_temp_for_city("New York")=={'temperature': 290.05}
  assert get_temp_for_city("London")=={'temperature': 288.67}
  assert get_temp_for_city("")=={'error': 'Invalid city name'}
  assert get_temp_for_city(123)=={'error': 'Invalid city name'}
  assert get_temp_for_city({'city': 'Paris'})=={'temperature': 286.92}
output: 
  def get_temp_for_city(city):
      if not isinstance(city, str) or not city:
          return {'error': 'Invalid city name'}
      
      api_key = 'your_api_key_here'
      base_url = f'http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}'
      
      try:
          response = requests.get(base_url)
          response.raise_for_status()
          data = response.json()
          temperature = data['main']['temp']
          return {'temperature': temperature}
      except (requests.RequestException, KeyError):
          return {'error': 'Failed to retrieve temperature'}
  