mirror of
https://github.com/jessebot/tiny_personal_website.git
synced 2025-10-01 01:48:43 +00:00
cleaning up a bit, adding sillies
This commit is contained in:
parent
d871a672d1
commit
e2ca07ab37
2 changed files with 51 additions and 40 deletions
33
personal_routes.py
Executable file
33
personal_routes.py
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/python
|
||||
# Jesse Hitch - JesseBot@Linux.com
|
||||
# 7/15/18 Production Web Routing File
|
||||
import bottle
|
||||
from bottle import redirect, request, response, route
|
||||
from bottle import run, static_file, template
|
||||
import logging as log
|
||||
import os
|
||||
import sys
|
||||
import yaml
|
||||
import personal_routes
|
||||
|
||||
|
||||
def get_global_variables():
|
||||
"""
|
||||
Gets global variables from YAML file. Returns dict.
|
||||
"""
|
||||
with open('./config/config.yaml', 'r') as f:
|
||||
doc = yaml.load(f)
|
||||
txt = doc["Globals"]
|
||||
return txt
|
||||
|
||||
|
||||
# full path to HTML templates
|
||||
WEB_ROOT = get_global_variables()['web_root']
|
||||
bottle.TEMPLATE_PATH.insert(0, '{0}/views/'.format(WEB_ROOT))
|
||||
|
||||
@route('/next-band')
|
||||
def dev():
|
||||
# Grab site specific information - YAML
|
||||
log.info("oh hi, you must be here to see the name of my next band")
|
||||
globals = get_global_variables()
|
||||
return template('next_band', globals=globals)
|
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
# Code by Jesse Hitch - JesseBot@Linux.com
|
||||
# 7/15/17
|
||||
# Production Web Routing File
|
||||
|
||||
# Jesse Hitch - JesseBot@Linux.com
|
||||
# 7/15/18 Production Web Routing File
|
||||
import bottle
|
||||
from bottle import redirect, request, response, route
|
||||
from bottle import run, static_file, template
|
||||
|
@ -10,71 +8,51 @@ import logging as log
|
|||
import os
|
||||
import sys
|
||||
import yaml
|
||||
import personal_routes
|
||||
|
||||
# set logging
|
||||
log.basicConfig(stream=sys.stderr, level=log.INFO)
|
||||
log.info("logging config loaded")
|
||||
|
||||
|
||||
def get_global_variables():
|
||||
""" gets global variable given string variable name"""
|
||||
"""
|
||||
Gets global variables from YAML file. Returns dict.
|
||||
"""
|
||||
with open('./config/config.yaml', 'r') as f:
|
||||
doc = yaml.load(f)
|
||||
txt = doc["Globals"]
|
||||
return txt
|
||||
|
||||
|
||||
def get_web_root():
|
||||
""" gets global variable given string variable name"""
|
||||
with open('./config/config.yaml', 'r') as f:
|
||||
doc = yaml.load(f)
|
||||
txt = doc["Globals"]['web_root']
|
||||
return txt
|
||||
|
||||
|
||||
# set logging
|
||||
log.basicConfig(stream=sys.stderr, level=log.INFO)
|
||||
log.info("logging config loaded")
|
||||
# Grab site specific information -YAML
|
||||
WEB_ROOT = get_web_root()
|
||||
# full path to HTML templates
|
||||
bottle.TEMPLATE_PATH.insert(0,
|
||||
'{0}/views/'.format(WEB_ROOT))
|
||||
WEB_ROOT = get_global_variables()['web_root']
|
||||
bottle.TEMPLATE_PATH.insert(0, '{0}/views/'.format(WEB_ROOT))
|
||||
|
||||
|
||||
@route('/')
|
||||
def index():
|
||||
# Grab site specific information - YAML
|
||||
log.info("oh hi, this is the route?")
|
||||
log.info("Good morning, sunshine. It's index time.")
|
||||
globals = get_global_variables()
|
||||
return template('index', globals=globals)
|
||||
|
||||
|
||||
@route('/robots.txt')
|
||||
def index():
|
||||
return static_file('robots.txt', root='{0}'.format(WEB_ROOT))
|
||||
def robots():
|
||||
return static_file('robots.txt', root=WEB_ROOT+'')
|
||||
|
||||
|
||||
@route('/images/<filename>')
|
||||
def images(filename):
|
||||
return static_file(filename, root='{0}/images'.format(WEB_ROOT))
|
||||
return static_file(filename, root=WEB_ROOT+'/images')
|
||||
|
||||
|
||||
@route('/css/<filename>')
|
||||
def css(filename):
|
||||
return static_file(filename, root='{0}/css'.format(WEB_ROOT))
|
||||
return static_file(filename, root=WEB_ROOT+'/css')
|
||||
|
||||
|
||||
@route('/fonts/<filename>')
|
||||
def fonts(filename):
|
||||
return static_file(filename, root='{0}/fonts'.format(WEB_ROOT))
|
||||
|
||||
|
||||
@route('/love')
|
||||
def love():
|
||||
# Grab site specific information - YAML
|
||||
globals = get_global_variables()
|
||||
return template('love', globals=globals)
|
||||
|
||||
|
||||
@route('/hate')
|
||||
def hate():
|
||||
# Grab site specific information - YAML
|
||||
globals = get_global_variables()
|
||||
return template('hate', globals=globals)
|
||||
return static_file(filename, root=WEB_ROOT+'/fonts')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue