នៅលើ server ដើម្បីទទួលយកទិន្នន័យដែលត្រូវបានបញ្ជូនចេញពី form តាមរបៀបដូចខាងលើនេះ យើងចាំបាច់ត្រូវភ្ជាប់ផ្លូវដែលតាមរយៈវា ទិន្នន័យត្រូវបានបញ្ជូនមក ទៅនឹង function ឬ method ណាមួយ ដោយធ្វើដូចខាងក្រោមនេះ៖
#c:\bottle\app.py from bottle import route, run, static_file from controllers import index, bicycle @route('/') def main(): kargs = {"title":"RENTAL BICYCLE"} return index.render(**kargs) @route('/static/scripts/<filename>') def server_static(filename): return static_file(filename, root='./public/scripts') @route('/static/styles/<filename>') def server_static(filename): return static_file(filename, root='./public/styles') @route('/static/images/<filename>') def server_static(filename): return static_file(filename, root='./public/images') @route('/static/fonts/<filename>') def server_static(filename): return static_file(filename, root='./public/fonts') run(host='localhost', port=9000, debug=True, reloader=True)
#c:\bottle\controllers\bicycle.py from bottle import request, post, template @post('/bicycle') def add(): brand = request.forms.get('fbrand') country = request.forms.get('fcountry') year = request.forms.get('fyear') amount = request.forms.get('famount') price = request.forms.get('fprice') bicycle = {'brand':brand, 'country':country, 'year':year, 'amount':amount, 'price':price} kargs = {"title":"ADD BICYCLE"} return template('index', data=kargs)ឯកសារទាំងអស់នៃកម្មវិធីនេះ មាននៅលើប្រព័ន្ទ GitHub: https://github.com/Sokhavuth/bicyclepy