A diode conducts (offers 0 resistance ideally i.e., it acts as a short circuit) only when it is forward biased and it offers very high impedance (in other words, it acts as a open circuit) when reverse biased. Thus, when an input is given to the diode (to its anode), only when the input is positive, it forward biases the diode, and so there will be current flow in the circuit, else the diode will not conduct and so there will be no current flow. This way u can make diode work as a switch, (only when voltage is +ve, u get an output current and when voltage is -ve, the current flow will be zero).