 	
 	
 }
+

        self.view_controller = view_controller
        super.init()
        if (CLLocationManager.locationServicesEnabled()){
            locationManager.delegate = self
            locationManager.desiredAccuracy = kCLLocationAccuracyBest
            locationManager.requestWhenInUseAuthorization()
            locationManager.startUpdatingLocation()
        }
        
        if(CMAltimeter.isRelativeAltitudeAvailable()){

        return .ok(.text(String(format: "%f", self.currentAltitude)))
    }
    func orientationRequest(request: HttpRequest) -> HttpResponse {
		guard let accel = self.acceleration else {
			return .internalServerError
		}
	
        var orientation: String = "In between"
        if(abs(accel.x + 1) < 0.1){
            orientation = "Landscape: home button on right"
        } else if(abs(accel.x - 1) < 0.15){
            orientation = "Landscape: home button on left"
        } else if(abs(accel.y + 1) < 0.15){
            orientation = "Portrait: home button on bottom"
        } else if(abs(accel.y - 1) < 0.15){
            orientation = "Portrait: home button on top"
        } else if(abs(accel.z + 1) < 0.15){
            orientation = "Faceup"
        } else if(abs(accel.z - 1) < 0.15){
            orientation = "Facedown"
        }
		
        return .ok(.text(orientation))

    }
	
	//Gives us the current acceleration in G's
	fileprivate var acceleration: CMAcceleration! {
		var currentAccel: CMAcceleration! = nil
		
		if self.motionManager.isDeviceMotionActive {
			if let grav = self.motionManager.deviceMotion?.gravity,
				let user = self.motionManager.deviceMotion?.userAcceleration {
				currentAccel = CMAcceleration(x: grav.x + user.x, y: grav.y + user.y,
				                              z: grav.z + user.z)
			}
		} else if self.motionManager.isAccelerometerActive {
			currentAccel = self.motionManager.accelerometerData?.acceleration
		}
		
		return currentAccel
	}
	
    func accelerationRequest(request: HttpRequest) -> HttpResponse {
		if let accel = self.acceleration {
			//We convert from G's to ms^-2 by multiplying by 9.81
			return .ok(.text("\(accel.x * 9.81) \(accel.y * 9.81) \(accel.z * 9.81)"))
		} else {
			return .internalServerError
		}
    }
    func dialogResponseRequest(request: HttpRequest) -> HttpResponse {
        if let response = self.last_dialog_response {
