We introduce a method for the all-electron calculation of the NMR chemical shifts and the EPR g tensor using the Gaussian and augmented-plane-wave method. The presented approach is based on the generalized density functional perturbation theory. The method is validated by comparison with other theoretical methods for a selection of small molecules. We also present two exemplary applications that involve the calculation of the chemical shifts of a hydrated adenine and the g tensor for the E(1)(') center in alpha-quartz using a quantum mechanical/molecular mechanical approach.