<filename>main.py
"""
Main entry point
"""

from src.app import create_app

if __name__ == "__main__":
    app = create_app()
    print("main")
    app.run()


# import logging
# import os
# import pathlib
# import sys
# import urllib.parse
#
# _path_apps = {}
#
# def wv_static_server(path):
#     global _path_apps
#
#     from webview import StaticFiles
#     from webview.serving import get_wsgi_server
#
#     rootdir, filename = os.path.split(path)
#
#     # Get/Build a WSGI app to serve the path and spin it up
#     if rootdir not in _path_apps:
#         _path_apps[rootdir] = StaticFiles(rootdir)
#     url = get_wsgi_server(_path_apps[rootdir])
#
#     if filename is not None:
#         url = urllib.parse.urljoin(url, filename)
#
#     return url
#
#
# if __name__ == "__main__":
#     # logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
#
#     import webview
#     import webview.serving
#
#     def get_current_url(current_window: webview.window.Window) -> None:
#         """
#         Spit out the current URL for use in debugging with an external browser
#         :param current_window: Current pywebview application window
#         :return: None
#         """
#         print(current_window.get_current_url())
#
#     def open_file_dialog(window):
#
#         get_current_url(window)
#
#         file_types = ('Video Files (*.mp4)', 'All files (*.*)')
#
#         result = window.create_file_dialog(webview.OPEN_DIALOG,
#                                          allow_multiple=False,
#                                          file_types=file_types)
#
#         resolved_url = wv_static_server(result[0])
#         print(fr"Opening `{result[0]}` from `{resolved_url}`")
#
#         window.evaluate_js(
#             rf"""
#                 var vid = document.createElement('video');
#                 vid.class = "rounded-lg overflow-hidden";
#                 var vid_src = document.createElement('source');
#                 vid_src.src = "{resolved_url}";
#                 vid_src.type = "video/mp4";
#                 vid.appendChild(vid_src);
#                 document.getElementById('video-container').appendChild(vid);
#
#             """
#         )
#         # window.evaluate_js(
#         #     r"""
#         #         $(document).ready(function($) {
#         #             $('#video-container').mediaelementplayer();
#         #         });
#         #     """
#         # )
#
#     window = webview.create_window('Captioneer v0.1', 'static/index.html', confirm_close=True)
#
#     # TODO: get_current_url can be attached to window.loaded, where current_window = webview.windows[0]
#     webview.start(open_file_dialog, window, debug=True, http_server=True)

<filename>main.py
"""
Main entry point
"""

from src.app import create_app

if __name__ == "__main__":
    app = create_app()
    print("main")
    app.run()


# import logging
# import os
# import pathlib
# import sys
# import urllib.parse
#
# _path_apps = {}
#
# def wv_static_server(path):
#     global _path_apps
#
#     from webview import StaticFiles
#     from webview.serving import get_wsgi_server
#
#     rootdir, filename = os.path.split(path)
#
#     # Get/Build a WSGI app to serve the path and spin it up
#     if rootdir not in _path_apps:
#         _path_apps[rootdir] = StaticFiles(rootdir)
#     url = get_wsgi_server(_path_apps[rootdir])
#
#     if filename is not None:
#         url = urllib.parse.urljoin(url, filename)
#
#     return url
#
#
# if __name__ == "__main__":
#     # logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
#
#     import webview
#     import webview.serving
#
#     def get_current_url(current_window: webview.window.Window) -> None:
#         """
#         Spit out the current URL for use in debugging with an external browser
#         :param current_window: Current pywebview application window
#         :return: None
#         """
#         print(current_window.get_current_url())
#
#     def open_file_dialog(window):
#
#         get_current_url(window)
#
#         file_types = ('Video Files (*.mp4)', 'All files (*.*)')
#
#         result = window.create_file_dialog(webview.OPEN_DIALOG,
#                                          allow_multiple=False,
#                                          file_types=file_types)
#
#         resolved_url = wv_static_server(result[0])
#         print(fr"Opening `{result[0]}` from `{resolved_url}`")
#
#         window.evaluate_js(
#             rf"""
#                 var vid = document.createElement('video');
#                 vid.class = "rounded-lg overflow-hidden";
#                 var vid_src = document.createElement('source');
#                 vid_src.src = "{resolved_url}";
#                 vid_src.type = "video/mp4";
#                 vid.appendChild(vid_src);
#                 document.getElementById('video-container').appendChild(vid);
#
#             """
#         )
#         # window.evaluate_js(
#         #     r"""
#         #         $(document).ready(function($) {
#         #             $('#video-container').mediaelementplayer();
#         #         });
#         #     """
#         # )
#
#     window = webview.create_window('Captioneer v0.1', 'static/index.html', confirm_close=True)
#
#     # TODO: get_current_url can be attached to window.loaded, where current_window = webview.windows[0]
#     webview.start(open_file_dialog, window, debug=True, http_server=True)

Main entry point # import logging # import os # import pathlib # import sys # import urllib.parse # # _path_apps = {} # # def wv_static_server(path): #     global _path_apps # #     from webview import StaticFiles #     from webview.serving import get_wsgi_server # #     rootdir, filename = os.path.split(path) # #     # Get/Build a WSGI app to serve the path and spin it up #     if rootdir not in _path_apps: #         _path_apps[rootdir] = StaticFiles(rootdir) #     url = get_wsgi_server(_path_apps[rootdir]) # #     if filename is not None: #         url = urllib.parse.urljoin(url, filename) # #     return url # # # if __name__ == "__main__": #     # logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) # #     import webview #     import webview.serving # #     def get_current_url(current_window: webview.window.Window) -> None: #         """ #         Spit out the current URL for use in debugging with an external browser #         :param current_window: Current pywebview application window #         :return: None #         """ #         print(current_window.get_current_url()) # #     def open_file_dialog(window): # #         get_current_url(window) # #         file_types = ('Video Files (*.mp4)', 'All files (*.*)') # #         result = window.create_file_dialog(webview.OPEN_DIALOG, #                                          allow_multiple=False, #                                          file_types=file_types) # #         resolved_url = wv_static_server(result[0]) #         print(fr"Opening `{result[0]}` from `{resolved_url}`") # #         window.evaluate_js( #             rf""" #                 var vid = document.createElement('video'); #                 vid.class = "rounded-lg overflow-hidden"; #                 var vid_src = document.createElement('source'); #                 vid_src.src = "{resolved_url}"; #                 vid_src.type = "video/mp4"; #                 vid.appendChild(vid_src); #                 document.getElementById('video-container').appendChild(vid); # #             """ #         ) #         # window.evaluate_js( #         #     r""" #         #         $(document).ready(function($) { #         #             $('#video-container').mediaelementplayer(); #         #         }); #         #     """ #         # ) # #     window = webview.create_window('Captioneer v0.1', 'static/index.html', confirm_close=True) # #     # TODO: get_current_url can be attached to window.loaded, where current_window = webview.windows[0] #     webview.start(open_file_dialog, window, debug=True, http_server=True)