Skip to content

Instantly share code, notes, and snippets.

@TutorialDoctor
Last active February 2, 2017 04:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save TutorialDoctor/5c022ff79f44be2c82cd to your computer and use it in GitHub Desktop.
Save TutorialDoctor/5c022ff79f44be2c82cd to your computer and use it in GitHub Desktop.
Automatically generates simple HTML, CSS, Javascript, and Python files for a website template.
# coding: utf-8
# Place this file in any directory and run it.
# An HTML, CSS, Javascript, and Python file will be generated in the directory.
# Double click the html file to test it in a browser.
# That's it (Edit as you will)
WRITE= 'w'
READ= 'r'
APPEND = 'a'
READWRITE = 'w+'
html_file = 'index.html'
css_file = 'style.css'
javascript_file = 'script.js'
python_file = 'code.py'
html_code = """<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<link href='style.css' rel='stylesheet'>
<script src='script.js' type='text/javascript'></script>
</head>
<body>
<p>Text Here: </p>
</body>
</html>"""
css_code = "p{color:red}"
javascript_code = "document.write('Javascript working')"
python_code = """html_file = "index.html"
with open(html_file,"a") as infile:
infile.write("Python Working ")
infile.write("<script>document.write('Yasss!')</script>")
"""
with open(html_file,mode=WRITE) as infile:
infile.write(html_code)
with open(css_file,mode=WRITE) as infile:
infile.write(css_code)
with open(javascript_file,mode=WRITE) as infile:
infile.write(javascript_code)
with open(python_file,mode=WRITE) as infile:
infile.write(python_code)
# Deleting the code below will not break anything, but it is for demonstration purposes
execfile(python_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment