import openai
import os

openai.api_key = os.environ["OPENAI_API_KEY"]

def generate_webpage(prompt):
    response = openai.Completion.create(
        engine="text-davinci-002",
        prompt=prompt,
        max_tokens=1024,
        n=1,
        stop=None,
        temperature=0.5,
    )

    return response.choices[0].text.strip()

generated_html = generate_webpage("Create a simple webpage with a header and a paragraph.")

with open("generated_webpage.html", "w") as f:
    f.write(generated_html)
    

Decode.jp