$\def\d{\mathrm{d}}$Show that if $f \in C^1[a,b]$ and $f(a)=f(b)=0$, then $$\int_a^b |f(x)|^2 \,\d x \le \frac{(b-a)^2}{\pi^2}\int_a^b |f'(x)|^2 \,\d x.$$
By a change of variable, it suffices to assume that $a=0$ and $b=\dfrac{1}{2}$. Extend $f$ to $\left[-\dfrac{1}{2},\dfrac{1}{2}\right]$ by setting $f(-x)=-f(x)$, then extend $f$ to be periodic on $\mathbb{R}$, $f$ thus extended is in $C^1(\mathbb{T})$.
$$\hat{f}(k)=\int_{-\frac{1}{2}}^{\frac{1}{2}}f(x)e^{-2ik\pi x} \,\d x=\frac{1}{ik\pi}\int_0^{\frac{1}{2}}f'(x)e^{-2i\pi kx} \,\d x=\frac{1}{2i\pi k}\hat{f'}(k).$$
Now $$\sum_{k\in \mathbb{Z}}|\hat{f}(k)|^2=\sum_{k\in \mathbb{Z}}\frac{1}{4\pi^2k^2}|\hat{f'}(k)|^2\le \frac{1}{4\pi^2}\sum_{k \in \mathbb{Z}}|\hat{f'}(k)|^2.$$
This gives us that $$\int_{0}^{\frac{1}{2}}|f(x)|^2 \,\d x \le \frac{1}{4\pi^2}\int_0^{\frac{1}{2}}|f'(x)|^2 \,\d x.$$
For the general case define $g:\left[0,\dfrac{1}{2}\right] \to \mathbb{R}$ by $g(x)=f(2(b-a)x+a)$. Then by the above we have $$\int_0^{\frac{1}{2}}|g(x)|^2\,\d x \le \frac{1}{4\pi^2}\int_0^{\frac{1}{2}}|g'(x)|^2\,\d x,$$ which gives that $$\int_{0}^{\frac{1}{2}}|f(2(b-a)x+a)|^2\,\d x \le \frac{1}{4\pi^2}\int_0^{\frac{1}{2}}|f'(2(b-a)x+a)|^24(b-a)^2\,\d x.$$
Let $u=2(b-a)x+a$. Then $\d u=2(b-a)\,\d x$ and the integral changes to $$\int_{a}^b|f(u)|^2\,\d u \le \frac{(b-a)^2}{\pi^2}\int_a^b|f'(u)|^2\,\d u.$$