#!/usr/bin/env python
# -*- coding: utf-8 -*-
from bottle import route, run, view, static_file, url,
redirect
import datetime
@route('/static/<filepath:path>',
name='static_file')
def static(filepath):
print("Start staic")
return static_file(filepath,
root="./static")
@route('/')
@view("sample")
def index():
print("Start index")
now = datetime.datetime.now()
timeString = now.strftime("%Y-%m-%d
%H:%M")
#../views/main.html
#return template('sample',
title='HELLO', name='bottle!', ampm=1, time=timeString,
url=url)
print("url={}".format(url))
return dict(title='HELLO',
name='bottle!', ampm=1, time=timeString, url=url)
@route('/hello')
def hello():
return "Hello World!"
@route('/move')
def move():
print("redirect to root")
redirect("/")
if __name__ == "__main__":
print("Reloading...")
run(host='0.0.0.0', port=8081,
debug=True, reloader=True)
|