Pairing in one-atomic-layer-thick two-dimensional electron gas (2DEG) by a single flat band of high-energy longitudinal optical phonons is considered. The polar dielectric SrTiO3 (STO) exhibits such an energetic phonon mode and the 2DEG is created both when one unit cell FeSe layer is grown on its 100 surface and on the interface with another dielectric like LaAlO3 (LAO). We obtain a quantitative description of both systems solving the gap equation for Tc for arbitrary Fermi energy ϵF, electron-phonon coupling λ, and the phonon frequency Ω, and direct (random-phase approximation) electron-electron repulsion strength α. The focus is on the intermediate region between the adiabatic, ϵF>>Ω, and the nonadiabatic, ϵF<<Ω, regimes. The high-temperature superconductivity in single-unit-cell FeSe/STO is possible due to a combination of three factors: high-longitudinal-optical phonon frequency, large electron-phonon coupling λ∼0.5, and huge dielectric constant of the substrate suppression the Coulomb repulsion. It is shown that very low density electron gas in the interfaces is still capable of generating superconductivity of the order of 0.1 K in LAO/STO.