Perubahan handler di pertemuan selasa kemarin
This commit is contained in:
parent
eb8c96233c
commit
e03d4eced2
@ -4,7 +4,7 @@ host = "localhost"
|
||||
port = 11000
|
||||
reloader = False
|
||||
debug = False
|
||||
server = 'gunicorn' # default = 'wsgiref'
|
||||
server = 'wsgiref' # default = 'wsgiref'
|
||||
|
||||
session_opts = {
|
||||
'session.type': 'file',
|
||||
|
18
handler.py
18
handler.py
@ -5,9 +5,11 @@
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
# You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
|
||||
from bottle import Bottle, route
|
||||
from bottle import Bottle, route, request, response
|
||||
from config import directory
|
||||
|
||||
import json
|
||||
|
||||
import templates.plain.main as template_public
|
||||
import modules.public.home as public_home
|
||||
|
||||
@ -21,3 +23,17 @@ def index():
|
||||
}
|
||||
}
|
||||
return public_home.main().html(params)
|
||||
|
||||
@app.route('/api/<crud>', method=['GET', 'POST', 'OPTIONS', 'PUT', 'DELETE'] )
|
||||
def contoh(crud):
|
||||
response.content_type = 'application/json'
|
||||
|
||||
params = request.json
|
||||
|
||||
keluaran = {
|
||||
"status":"success",
|
||||
"Message":"API SUKSES!",
|
||||
"endpoint":f"/api/{crud}"
|
||||
}
|
||||
|
||||
return json.dumps(keluaran).encode()
|
Loading…
Reference in New Issue
Block a user