$f\in L^2(0,1)$ if and only if $f\in L^1(0,1)$ and ere exists an increasing function $g:[0,1]\rightarrow \mathbb{R}$ such that $$\left|\int_a^b f(x) dx \right|^2 \leq (g(b)-g(a))(b-a)\quad\quad (*)$$ for all $0\leq a \leq b \leq 1$.
For $(\Rightarrow)$, it follows from Jensen's inequality that $$\left|\int_a^b f(x) dx \right|^2 \leq (b-a) \int_a^b |f(x)|^2 dx$$ so just take $g(x) = \int_0^x |f(t)|^2 dt$.
For $(\Leftarrow)$, I am not so sure. First I know that $\frac{1}{2\sqrt{x}}\in L^1(0,1)$ but it is not in $L^2(0,1)$, and I tried to see where $(*)$ would fail $$(\sqrt{b} - \sqrt{a})^2 \leq (g(b)- g(a)) (b-a)$$ $$(\sqrt{b} - \sqrt{a}) \leq (g(b)- g(a)) (\sqrt b + \sqrt a),$$ then how do I know that no such increasing function $g$ exists?
I would really appreciate if you could provide me with some hints for the 2nd part, thanks!
Edit: I think I figured this out. Check my answer below.
Okay, so from $(*)$, we have $$\bigg|\frac{1}{b-a} \int_0^1 f(x) dx \bigg|^2 \leq \frac{g(b)-g(a)}{b-a},$$ take the limit as $b \rightarrow a$, since Lebesgue points are a.e and monotone function $g$ is differentiable a.e, we have the following pointwise a.e inequality $$|f(a)|^2 \leq g'(a).$$ Now integrate both sides, $$\int_0^1 |f(x)|^2 dx \leq \int_0^1 g'(x) dx \leq g(1)-g(0) <\infty.$$