#index.py
import sys
from routes import index

app = index.app

if sys.platform == 'win32':
    app.run(host='localhost', port=7000, debug=True, reloader=True)

 

#routes/index.py
from bottle import Bottle, template, static_file, request, response

app = Bottle()

@app.route('/static/images/<filename>')
def loadImage(filename):
    return static_file(filename, root='./asset/img')


@app.route('/static/styles/<filename>')
def loadStyle(filename):
    return static_file(filename, root='./asset/css')


@app.route('/static/styles/partials/<filename>')
def loadStylePartial(filename):
    return static_file(filename, root='./asset/css/partials')


@app.route('/static/scripts/<filename>')
def loadScript(filename):
    return static_file(filename, root='./asset/js')


@app.route('/static/scripts/ckeditor/<filename>')
def loadCKEditorScript(filename):
    return static_file(filename, root='./asset/js/ckeditor')


@app.route('/static/fonts/<filename>')
def loadFont(filename):
    return static_file(filename, root='./asset/font')


@app.route('/')
def index():
    return template('index', data={'title': 'Khmer Web REST API'})

 

<!--views/base.tpl-->
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>{{ data['title'] }}</title>
    <script src="/static/scripts/jQuery.js"></script>
    <link href="/static/images/site_logo.png" rel="icon" ></link>
    <link href="/static/fonts/setup.css" rel="stylesheet"></link>
  </head>
  <body>
    {{!base}}
  </body>
</html>

 

<!--views/index.tpl-->
% rebase('base.tpl')
<p>Page Content ...</p>

 

GitHub: https://github.com/Sokhavuth/REST-API

Vercel: https://rest-api-zeta.vercel.app