Rental Bicycle App: Bicycle Entry Form & Route

ដើម្បី​អាច​អោយ​កម្មវិធី Rental Bicycle App មាន​លទ្ធផលភាព​អាច​បញ្ចេញ​បញ្ចូល​ទិន្នន័យ​ស្តី​ពី​កង់​ត្រូវ​ជួល ពី​និង​ទៅ​ក្នុង​មូលដ្ខាន​ទិន្នន័យ SQLite បាន យើង​ចាំបាច់​ត្រូវ​បង្កើត​ form មួយ​សិន រួម​ទាំង​កំនត់​ផ្លូវ​ចូល​ទៅ​កាន់​ form នោះ​ផង​ដែរ​។ ពិនិត្យ​កូដ​ខាង​ក្រោម​នេះ៖

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!--\views\bikeform.tpl-->
 
%include("./partials/header.tpl")
 
<style>
#bikeform{
  margin-top: 30px;
  width: 30%;
  display: grid;
  grid-template-columns: auto calc(85% - 5px);
  grid-gap: 5px;
}
#bikeform a{
  text-align: right;
}
</style>
 
<div class="main" id="main">
  <div class="content" id="content">
    <span>BICYCLE ENTRY FORM</span>
    <form id="bikeform" method="POST" action="/bikeform" onsubmit="return bicycle.bicycleForm('bikeform')">
      <a>Brand:</a><input name="fbrand" type="text">
      <a>Country:</a><input name="fcountry" type="text">
      <a>Year:</a><input name="fyear" type="text">
      <a>Amount:</a><input name="famount" type="text">
      <a>Price:</a><input name="fprice" type="text">
      <a></a><input type="submit">
    </form>
  </div><!--content-->
 
</div><!--main-->
 
%include("./partials/footer")
1
2
3
4
5
6
7
#\controllers\bikeform.py
import config
from bottle import template, route
 
@route("/bikeform")
def renderForm():
  return template('bikeform', data=config.kargs)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#\app.py
import os, config
from bottle import route, run
from controllers import index, bikeform
from public import setup
   
@route('/')
def main():
  return index.render(**config.kargs)
   
if 'DYNO' in os.environ:
  run(host='0.0.0.0', port=os.environ.get('PORT', 9000))
else:
  run(host='localhost', port=9000, debug=True, reloader=True)
  

GitHub: https://github.com/Sokhavuth/Rental-Bicycle-App
Heroku: https://khmerweb-rba.herokuapp.com/