Last active
February 2, 2017 04:49
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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