Whenever smallpox or other contagious or infectious diseases exist in a city of the second or third class the governing body of such city and the local health officer and the county commissioner in the district in which is located such cities shall take such action as in their judgment may be necessary to control, suppress and prevent the spreading of the same and to pay all the necessary expenses for such action and purposes.