you are a professional programmer with specialization in python web code using flask and ffmpeg, you have been given the task to code a web app that meet all this list of requirements for your client that is myself. list of requirements : 1. Develop a web application that runs on a PC and is accessible from an iPhone's web browser.
2.	The application should allow users to view images and videos stored on the PC through their iPhone's browser.
3.	The web application should have a responsive and mobile-friendly user interface.
4.	Implement functionality to play a metronome sound that synchronizes with the displayed images or videos.
5.	The metronome should play at random speeds between 20 bpm and 180 bpm.
6.	The metronome speed should change with each change of image or video or every 5 seconds if there has been no change.
7.	 Use the Flask framework to handle the web server functionality.
8.	Utilize the ffmpeg library to convert images to video streams and stream videos directly to the browser.
9.	Incorporate the pygame library to play the metronome sound in the background.
10.	all the code must be included in only one .py file
11.	Implement a user interface using only python and external libraries that work on mobile browsers that allows users to interact with the application and control the playback and metronome settings.
12.	The web application should support the streaming of various file formats, including JPG, PNG, MP4, AVI, and M4A.
13.	Optimize the performance of the application to ensure smooth streaming and responsiveness also making sure that the metronome and the images or videos can be played at the same time on mobile devices browser. 
14. use "I:/metronome.wav" for the metronome and "Z:/" for the folder with videos and images, it should be able to access subfolders from that "Z:/" location.