בנית אתר פשוט על גיטלאב

Python GitLab

אם אתם יוצרים דף לפי הדוגמא הזאת, תפתכו issue ב פרויקט שלי

examples/gitlab-pages/.gitlab-ci.yml

pages:
  image: python:3.11
  script:
    - python -V
    - python generate.py
  artifacts:
    paths:
      - public
  only:
    - main

examples/gitlab-pages/generate.py

import pathlib
import datetime

folder = "public"
filename = "index.html"

path = pathlib.Path(folder)
if not path.exists():
    path.mkdir()

now = datetime.datetime.now()

html = f"""
<!DOCTYPE html>
<html>
<head>
    <title>My Website create by Python</title>
</head>
<body>
    <h1>Hello, World!</h1>
    Published: {now}
</body>
</html>
"""

with open(path.joinpath(filename), "w") as file:
    file.write(html)

Author

Gabor Szabo (szabgab) Gabor Szabo