Skip to content

Instantly share code, notes, and snippets.

@futoase
Created February 14, 2012 12:24
Show Gist options
  • Select an option

  • Save futoase/1826438 to your computer and use it in GitHub Desktop.

Select an option

Save futoase/1826438 to your computer and use it in GitHub Desktop.
bottle skeleton maker
#!/usr/bin/env python
# -*- coding:utf-8 -*-
DEBUG = True
RELOAD = True
import os
import sys
INDEX_TPL = (
'''
<html>
<head>
<meta charset="UTF-8"/>
<link rel="stylesheet" src="main.css"/>
<title>hello world</title>
</head>
<body>
<div>
<h1>hello world</h1>
</div>
</body>
</html>
'''.strip())
MAIN_CSS = (
'''
body {
background-color: #ccc;
color: #222;
}
'''.strip())
SOURCE_TPL = (
'''
#!/usr/bin/env python
# -*- coding:utf-8 -*-
DEBUG = True
RELOAD = True
from bottle import route, template, static_file, debug, run
@route('/')
def index():
return template('index')
@route('/static/<path:path>')
def static(path):
return static_file(path)
if __name__ == '__main__':
debug(DEBUG)
run(host='localhost', port=8080, reloader=RELOAD)
'''.strip())
DIRS = ['static', 'views']
def run():
for d in DIRS:
if not os.path.exists(d):
os.makedirs(d)
with open('app.py', 'w') as f:
f.write(SOURCE_TPL)
with open('static/main.css', 'w') as f:
f.write(MAIN_CSS)
with open('views/index.tpl', 'w') as f:
f.write(INDEX_TPL)
if __name__ == '__main__':
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment