input: Write a function to design a web server in Python using the Flask framework that would serve a JSON object containing the current temperature for a city based on the city name given in the request. If the request is successful, return the temperature; otherwise, handle any errors appropriately. If the city name is not provided, return an error message.
  app = Flask(__name__)
  
  @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))
          weather = json.loads(r.text)
          return {'temperature': weather['main']['temp']}
      except KeyError:
          return {'error': 'City name not provided'}, 400
      except Exception as e:
          return {'error': str(e)}, 500
  
  if __name__ == '__main__':
      app.run(debug=True)
  assert get_temp({'city': 'London'}) == {'temperature': 280.32}
  assert get_temp({'city': 'New York City'}) == {'temperature': 279.45}
  assert get_temp({}) == {'error': 'City name not provided'}
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))
          weather = json.loads(r.text)
          return {'temperature': weather['main']['temp']}
      except KeyError:
          return {'error': 'City name not provided'}, 400
      except Exception as e:
          return {'error': str(e)}, 500
  