I was thinking some about weak homotopy equivalences and what happens when you drop the continuity assumption. For example, it's not too hard to come up with non-continuous functions that induce isomorphisms on all homotopy groups (and a bijection on connected components): let $X$ be any contractible space, then the identity map $\operatorname{codisc}X\to X$ from the codiscrete topology on $X$ is not continuous in general, but it trivially induces isomorphisms of all $\pi_n$ as both spaces are contractible.
My question is if continuity remains unnecessary if I strengthen the assumptions a bit from just inducing homomorphisms of homotopy groups to actually just preserving homotopies:
Question: Does there exist a non-continuous map $f:X\to Y$ such that $\def\bS{\mathbb{S}}fg:\bS^n\to Y$ is continuous for all continuous $g:\bS^n\to X$ and $n\geq0$, where $\bS^n$ is the $n$-sphere?
I want to believe that the answer is yes, but I am drawing blanks for an explicit example. I thought to use length constraints on homotopies like what happens with the long line (each individual homotopy is "too small" to see everything), but I couldn't put it into practice.
If the answer to the question is indeed yes, then how nice can $X$ and $Y$ be with $f$ still existing? For instance, can $X$ and $Y$ be compactly generated and (weakly) Hausdorff?