Skip to content

Instantly share code, notes, and snippets.

@DEKHTIARJonathan
Created November 13, 2016 15:19
Show Gist options
  • Save DEKHTIARJonathan/0e7d718ea5fed1e944b2db9a1fe6eae5 to your computer and use it in GitHub Desktop.
Save DEKHTIARJonathan/0e7d718ea5fed1e944b2db9a1fe6eae5 to your computer and use it in GitHub Desktop.
Rapid API Prototyping with Bottle.py - API.py v1
####################### Import Libraries #######################
import os.path
from bottle import route, run, response, static_file, request, error, Bottle, template
from json import dumps, loads, load
####################### WebService Route / #######################
class API:
def __init__(self, port, local):
self._app = Bottle()
self._local = local
self._port = port
if local:
self._host = '127.0.0.1'
else:
self._host = '0.0.0.0'
def start(self):
self._app.run(server='paste', host=self._host, port=self._port)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment