From bab81b17b5d3e6412fa3f4b22fb84c4a5c29ccca Mon Sep 17 00:00:00 2001 From: BSd3v <82055130+BSd3v@users.noreply.github.com> Date: Fri, 11 Oct 2024 11:20:35 -0400 Subject: [PATCH] updating to allow for all files to be passed from the `PRs` directory, this should allow for pages, etc. --- PRs/app.py | 7 ++----- PRs/pages/home.py | 9 +++++++++ tmp_deploy.py | 29 +++++++++++++++-------------- 3 files changed, 26 insertions(+), 19 deletions(-) create mode 100644 PRs/pages/home.py diff --git a/PRs/app.py b/PRs/app.py index 52f88b50..8e2a20e8 100644 --- a/PRs/app.py +++ b/PRs/app.py @@ -4,11 +4,8 @@ _dash_renderer._set_react_version("18.2.0") -app = Dash(__name__) +app = Dash(__name__, use_pages=True) -app.layout = dmc.MantineProvider([ - html.Div('Hi PyCafe'), - dmc.MultiSelect(data=['Test1', 'Test2']) - ]) +app.layout = dmc.MantineProvider(page_container) app.run() \ No newline at end of file diff --git a/PRs/pages/home.py b/PRs/pages/home.py new file mode 100644 index 00000000..5e08fc0f --- /dev/null +++ b/PRs/pages/home.py @@ -0,0 +1,9 @@ +from dash import * +import dash_mantine_components as dmc + +layout = [ + html.Div('Hi PyCafe'), + dmc.MultiSelect(data=['Test1', 'Test2']) + ] + +register_page(__name__, path='/') \ No newline at end of file diff --git a/tmp_deploy.py b/tmp_deploy.py index bb8315e2..558bd43b 100644 --- a/tmp_deploy.py +++ b/tmp_deploy.py @@ -9,26 +9,27 @@ files = [] code = '' reqs = {} -for f in os.listdir('PRs'): - file_path = os.path.join('PRs', f) - if f not in ['app.py','requirements.txt']: - with open(file_path, 'rb') as file: +for root, dirs, filenames in os.walk('PRs'): + for f in filenames: + file_path = os.path.join(root, f) + if f not in ['app.py', 'requirements.txt']: + with open(file_path, 'rb') as file: files.append( { - "name": f, + "name": os.path.relpath(file_path, 'PRs'), "content": base64.b64encode(file.read()).decode("utf8"), "encoding": "base64" } ) - elif f == 'app.py': - with open(file_path, 'r') as file: - code = file.read() - else: - with open(file_path, 'r') as file: - reqs = { - 'name': f, - 'content': file.read() - } + elif f == 'app.py': + with open(file_path, 'r') as file: + code = file.read() + elif f == 'requirements.txt': + with open(file_path, 'r') as file: + reqs = { + 'name': os.path.relpath(file_path, 'PRs'), + 'content': file.read() + } new_package = f'{os.getenv("PACKAGE_NAME")} @ https://py.cafe/gh/artifact/{os.getenv("GITHUB_REPOSITORY")}/{os.getenv("ARTIFACT_ID")}/{os.getenv("FILE_FULLNAME")}' if os.getenv("PACKAGE_NAME") in reqs['content']: