Is this set compact or not? 
Let X be a topological space and  $ f: X \to [0,1] $ be a closed continuous surjective map such that $f^{-1}(a)$ is compact for every $0\leq a\leq 1$. Prove or disprove: X is compact.

I thought of first trying to prove this. If I take $X\subseteq\bigcup_{i=1}^{\infty} O_i$. But the problem is that all the information given in the question is regarding the set on the RHS ie [0,1] like surjectivity , continuity.
So, I am unable to prove this.
Also, I am not good with the  constructing examples of topological spaces so I am not able to construct a closed map which is also continuous and surjective.
Can you please help?
 A: Yes, the statement is true, indeed a stronger statement is:
Theorem: Let $X,Y$ be Hausdorff spaces and let $f\colon X\to Y$ be a continuous closed surjection such that $f^{-1}(y)$ is compact for every $y\in Y$. Then $f$ is proper, meaning that if $Z\subseteq Y$ is compact, then $f^{-1}(Z)$ is also compact.
The proof below is taken from Engelking's General Topology, in the book this is Theorem 3.7.2.
Proof: Let$\{U_s\}_{s\in S}$ be a family of open subsets of $X$ such that $$f^{-1}(Z)\subseteq\bigcup_{s\in S}U_s.$$ We want to find a finite $S_0\subseteq S$ such that $$f^{-1}(Z)\subseteq\bigcup_{s\in S_0}U_s.$$
Let $\mathcal T=\{T\subseteq S\mid T\text{ is finite}\}$ and for $T\in\mathcal T$ let $U_T=\bigcup_{s\in T} U_s$, in other words $\{U_T\mid T\in \mathcal T\}$ is the family of all open sets that can be obtained as a finite union of the $U_s$. Now for $z\in Z$ we know that $f^{-1}(z)$ is compact, which implies that $f^{-1}(z)$ is contained in $U_{T_z}$ for some $T_z\in\mathcal T$. Moreover we have $$z\in Y\setminus f(X\setminus U_{T_z}),$$ and so
$$Z\subseteq \bigcup_{z\in Z} Y\setminus f(X\setminus U_{T_z}).$$
Since $f$ is closed $Y\setminus f(X\setminus U_{T_z})$ is open for all $z\in Z$, so by compactness of $Z$ we can find finitely many $z_i\in Z$ such that, denoting $U_{T_{z_i}}$ by $U_{T_i}$ for simplicity, we have $$Z\subseteq\bigcup_i Y\setminus f(X\setminus U_{T_i}).$$
But now we have
\begin{align}
f^{-1}(Z)&\subseteq \bigcup_i f^{-1}(Y\setminus f(X\setminus U_{T_i}))=\bigcup_i (X\setminus f^{-1}(f(X\setminus U_{T_i}))\\
&\subseteq\bigcup_i(X\setminus(X\setminus U_{T_i}))=\bigcup_i U_{T_i}=\bigcup_{s\in S_0}U_s,
\end{align}
where $S_0=\bigcup_i T_i$. $\square$
