If it appears from the petition for a writ of habeas corpus or from the documents thereunto annexed that the party is imprisoned and detained on any criminal charge or accusation, the officer issuing the writ must endorse thereon an order requiring the applicant, or someone else for him, to give notice to the district attorney of the circuit or to the prosecutor or principal agent in procuring the arrest of the issue of the writ and of the time and place at which it is returnable. If such notice is not given when the district attorney or other person entitled to it is within 50 miles of the place of examination, the party who is imprisoned must not be discharged. But, if the party is charged with an offense which is bailable and he waives an examination into the facts, the judge may fix the amount of bail, without notice to the district attorney or prosecutor, and in so doing, he must act on the presumption that the offense is of the highest grade.
Ala. Code § 15-21-13 (1975)