Created
March 21, 2016 09:26
-
-
Save last-ent/eedc154424d66c826f7c to your computer and use it in GitHub Desktop.
This file contains 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
import os | |
dirs = ["js", "css", "html"] | |
for _d in dirs: | |
try: | |
os.mkdir("./{}".format(_d)) | |
except: | |
pass | |
base_css = """ | |
#header h1 { | |
color: rgb(75, 113, 151); | |
font-variant: small-caps; | |
} | |
""" | |
hello_html = """ | |
<div id="header"> | |
<h1>Hello, World!</h1> | |
</div> | |
""" | |
start_server = """python -m SimpleHTTPServer 8000""" | |
start_js = """ | |
$(function () { | |
var start = function() { | |
console.log("In start"); | |
$.get("/html/" + appData["templates"]["hello"], function (data) { | |
$("#main").html( data); | |
}); | |
$.get("/css/"+appData["styles"]["base"], function (data) { | |
$("#layout-style").html(data); | |
}); | |
} | |
var appData = { | |
"routes": { | |
"#": start | |
}, | |
"presenter": { | |
}, | |
"templates": { | |
"hello": "hello.html" | |
}, | |
"styles": { | |
"base": "base.css" | |
} | |
} | |
appData["routes"]["#"](); | |
}); | |
""" | |
index = """ | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<head> | |
<meta charset="utf-8"></meta> | |
<meta content="width=device-width, initial-scale=1.0" name="viewport"></meta> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css"> | |
<style type="text/css" id="layout-style" href=""></style> | |
<script src="https://code.jquery.com/jquery-2.2.2.min.js" | |
integrity="sha256-36cp2Co+/62rEAAYHLmRCPIych47CvdM+uTBJwSzWjI=" | |
crossorigin="anonymous"></script> | |
<title>Hello, World!</title> | |
</head> | |
<body> | |
<div id="main"></div> | |
<script type="text/javascript"> | |
'use strict'; | |
$.get("/js/start.js", function (data) { | |
data(); | |
}) | |
</script> | |
</body> | |
</html> | |
""" | |
for (path, content) in [ | |
("html/hello.html", hello_html), | |
("css/base.css", base_css), | |
("index.html", index), | |
("start_server.sh", start_server), | |
("js/start.js", start_js)]: | |
try: | |
with open("./"+path, 'w') as f: | |
f.write(content) | |
except: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment