diff --git a/config/server.py b/config/server.py index 8c191b8..dbbd507 100644 --- a/config/server.py +++ b/config/server.py @@ -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', diff --git a/handler.py b/handler.py index 64ae435..d46d657 100644 --- a/handler.py +++ b/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/', 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() \ No newline at end of file