An emergency ordinance or resolution is an ordinance or resolution for the immediate preservation of the public peace, health or safety, in which the emergency is defined or declared in a preamble thereto, separately voted upon, and agreed to by at least four members of the council, as recorded by ayes and noes. An emergency ordinance or resolution must be in writing, but may be enacted without previous filing. No grant of any franchise shall be construed to be an emergency ordinance. No prosecution shall be based upon the provisions of any emergency ordinance until twenty four hours after the ordinance has been filed with the city clerk and posted in three conspicuous places, or until the ordinance has been published, unless the person charged with violation had actual notice of the passage of the ordinance prior to the act or omission complained of.