Suppose $f$ is an entire function such that $f(0) = 1$ and $\int_0^{2\pi} |f(e^{i\theta})| d\theta = 2\pi$. Show that $f$ must be a constant function. This is a problem from a previous qualifying exam in complex analysis that I'm working through to study for my own upcoming exam. I'm looking for whether or not my proof is correct and if there are ways to improve or simplify it. Thanks!
Problem:
Suppose $f$ is an entire function such that $f(0) = 1$ and $\int_0^{2\pi} |f(e^{i\theta})| d\theta = 2\pi$. Show that $f$ must be a constant function.
Original Attempt:
Since $f(z)$ is entire, consider Cauchy's Integral Formula
$$
f(a) = \frac{1}{2\pi i} \oint_\gamma \frac{f(z)}{z-a} dz
$$
for $a=0$ and with $\gamma$ as the unit circle, which yields
$$
f(0) = \frac{1}{2\pi i} \oint_\gamma \frac{f(z)}{z} dz = \frac{1}{2\pi i} \int_0^{2\pi} \frac{f(e^{i\theta})}{e^{i\theta}}\cdot ie^{i\theta} d\theta = \frac{1}{2\pi} \int_0^{2\pi} f(e^{i\theta}) d\theta = 1.
$$
Thus, we have
$$
\int_0^{2\pi} f(e^{i\theta}) d\theta = 2\pi \quad \implies \quad \left\vert \int_0^{2\pi} f(e^{i\theta}) d\theta \right\vert = |2\pi| = 2\pi. 
$$
Now, by the ML inequality (or estimation lemma), we also have that on the unit circle
$$
\left\vert \int_0^{2\pi} f(e^{i\theta}) d\theta \right\vert \leq \max_{|z|=1} \left\vert f(e^{i\theta}) \right\vert \cdot 2\pi.
$$
Since we already know that we actually have equality here, it must be that
$$
\max_{|z|=1} \left\vert f(e^{i\theta}) \right\vert = 1.
$$
But by the Maximum Modulus Principle, if $f(z)$ attains its maximum inside of the region $\gamma$, which we have at $f(0)=1$, then the function must be constant.
CURRENT ATTEMPT:
Since $f(z)$ is entire, consider Cauchy's Integral Formula
$$
f(a) = \frac{1}{2\pi i} \oint_\gamma \frac{f(z)}{z-a} dz
$$
for $a=0$ and with $\gamma$ as the unit circle, which yields
$$
f(0) = \frac{1}{2\pi i} \oint_\gamma \frac{f(z)}{z} dz = \frac{1}{2\pi i} \int_0^{2\pi} \frac{f(e^{i\theta})}{e^{i\theta}}\cdot ie^{i\theta} d\theta = \frac{1}{2\pi} \int_0^{2\pi} f(e^{i\theta}) d\theta = 1.
$$
Thus, we have
$$
\int_0^{2\pi} f(e^{i\theta}) d\theta = 2\pi. 
$$
and from the problem statement,
$$
\int_0^{2\pi} |f(e^{i\theta})| d\theta = 2\pi.
$$
Subtracting yields
$$
\int_0^{2\pi} \Big(|f(e^{i\theta})| - f(e^{i\theta})\Big) = 0 \quad \implies \quad |f(e^{i\theta})| = f(e^{i\theta})
$$
on the unit circle. Therefore, $0 < f(z)\in \mathbb{R}$ for $|z|=1$. Then on the unit circle $f(z) = u(x,y)+iv(x,y) = u(x,y)$ since the imaginary part $v(x,y)=0$. Since $f(z)$ is entire and thus analytic, the Cauchy Riemann equations hold and
$$
\frac{\partial u}{\partial x} = \frac{\partial v}{\partial y}, \quad \frac{\partial u}{\partial y} = -\frac{\partial v}{\partial x} .
$$
Since $v(x,y)=0$ on the unit circle,
$$
\frac{\partial u}{\partial x} = 0, \quad \frac{\partial u}{\partial y} = 0,
$$
thus $f(z)=u(x,y) = \alpha, \; \alpha \in \mathbb{R}$) and is constant on the unit circle $\gamma$. Then
$$
\alpha \int_0^{2\pi} d\theta = 2\pi \quad \implies \quad \alpha = 1.
$$
By the Maximum Modulus Principle, if $f(z)$ attains its maximum inside of the region $\gamma$, which we have at $f(0)=1$, then the function must be constant.
 A: Let $U$ denote the open unit ball.
The above shows that $\int (|f|-\operatorname{re} f) d \theta = 0$, from which we get $|f|=\operatorname{re} f$ on $\partial U$ and hence $f=|f|$ on $\partial U$.
Suppose $f$ is non constant, then we will show that $f$ takes non real values on $\partial U$ which is a contradiction.
The open mapping theorem shows that $f(U)$ is open, and since $U$ is bounded, so is $f(U)$. We can suppose that there is some $w_0 \in f(U)$ such that
$\operatorname{im} w_0 >0$. Let $t^* = \sup \{ t | w_0+it \in f(U) \}$ and $w^* = w_0+it^*$. Then there are $w_k \in f(U)$ such that $w_k \to w^*$. Note that $w^* \notin f(U)$.
Choose $u_k \in U$ such that $f(u_k) = w_k$, then there is some subsequence $K$ and $u^*$ such that $u_k \overset{K}{\to} u^*$, then we have $u \in \partial U$ and $f(u^*) = w^* \notin \mathbb{R}$ which gives us our contradiction.
Aside: Here is a cute way of finishing the proof once it is established that $f$ is real valued on $\partial U$. This was stolen from a comment by Dan Petersen in https://mathoverflow.net/q/380272/31729.
We have $a_{n} = {1 \over 2 \pi} \int_\gamma {f(z) \over z^{n+1}} dz$ where $\gamma(t) = e^{it}$.
Since $f$ is real on $\partial U$ we have (for $n$ a strictly positive integer)
$a_{-n} = \overline{a_n}$. Since $f$ is entire, we have $a_{-n} = 0$. Hence $f(z) = a_0 = f(0) = 1$.
