fix: build for multi page frontend

This commit is contained in:
Kentai Radiquum 2025-05-05 01:57:31 +05:00
parent af7b8a6fea
commit 7f704ec75a
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
3 changed files with 14 additions and 3 deletions

View file

@ -49,10 +49,19 @@ if __name__ == "__main__":
shutil.copyfile(f"./gui/out/{file}", f"{OUT_DIR}/static/{file}") shutil.copyfile(f"./gui/out/{file}", f"{OUT_DIR}/static/{file}")
for dir in dirs: for dir in dirs:
print(f"Copied directory: './gui/out/{dir}' -> '{OUT_DIR}/static/{dir}'") if dir == "_next":
print(f"Copied directory: './gui/out/{dir}' -> '{OUT_DIR}/static/{dir}'")
shutil.copytree(
f"./gui/out/{dir}", f"{OUT_DIR}/static/{dir}", dirs_exist_ok=True
)
continue
print(f"Copied directory: './gui/out/{dir}' -> '{OUT_DIR}/templates/{dir}'")
shutil.copytree( shutil.copytree(
f"./gui/out/{dir}", f"{OUT_DIR}/static/{dir}", dirs_exist_ok=True f"./gui/out/{dir}", f"{OUT_DIR}/templates/{dir}", dirs_exist_ok=True
) )
print(f"Copied app: './src' -> '{OUT_DIR}'") print(f"Copied app: './src' -> '{OUT_DIR}'")
shutil.copytree("./src", f"{OUT_DIR}/", dirs_exist_ok=True) shutil.copytree("./src", f"{OUT_DIR}/", dirs_exist_ok=True)
if os.path.exists(f"{OUT_DIR}/__pycache__") and os.path.isdir(f"{OUT_DIR}/__pycache__"):
shutil.rmtree(f"{OUT_DIR}/__pycache__")

View file

@ -1,4 +1,4 @@
const API = process.env.NEXT_PUBLIC_API_URL; const API = process.env.NEXT_PUBLIC_API_URL || "/api";
export const ENDPOINTS = { export const ENDPOINTS = {
createPack: `${API}/pack/new`, createPack: `${API}/pack/new`,

View file

@ -20,6 +20,8 @@ def index():
def rewrite_next(path): def rewrite_next(path):
if os.path.exists(f"./static/{path}"): if os.path.exists(f"./static/{path}"):
return send_file(f"./static/{path}") return send_file(f"./static/{path}")
if os.path.exists(f"./templates/{path}.html"):
return render_template(f"{path}.html")
return abort(404) return abort(404)