Ejemplo n.º 1
0
 def run_app(self):
     api_app = Bottle()
     api_app.install(log_to_logger)
     app.install(log_to_logger)
     api_app.mount('/api/', app)
     conf = self.get_config()
     api_app.config['host'] = conf['host']
     api_app.config['port'] = conf['port']
     api_app.run(host=api_app.config['host'], port=api_app.config['port'])
Ejemplo n.º 2
0
 def __init__(self):
     self.user = None
     self._read_settings()
     self.app = Bottle()
     if self._ssl:
         SSLify(self.app)
     self.bound_bottle()
     try:
         print(self._ssl)
         self.app.run(host=self.web_settings['host'],
                      port=int(self.web_settings['port']),
                      server='ssl' if self._ssl else 'wsgiref')
     except OSError as e:
         print(e)
Ejemplo n.º 3
0
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

from lib.bottle import Bottle
from lib.bottle import TEMPLATE_PATH
from lib.bottle import jinja2_template
from lib.bottle import request
from sample.models.data import website


app = Bottle()
TEMPLATE_PATH.append('../sample/views')


@app.route('/', method=["GET", "POST"])
def index():
    add_website_page = "add_website.html"
    login_page = "login.html"
    session = request.environ.get('beaker.session')
    user_id = session.get("user_id", "")
    # セッション情報が残っていた場合
    if user_id:
        cls_website = website.Website()
        attention = u""
        website_name = request.forms.decode().get('website_name', "")
        website_link = request.forms.decode().get('website_link', "")
        website_keywords = request.forms.decode().get('website_keywords', "")
        complete_add_website = request.forms.get('complete_add_website', "False")
        if website_link:
            if not website_name:
                website_name = cls_website.get_website_title_with_link(website_link)
Ejemplo n.º 4
0
# Licença Pública Geral GNU para maiores detalhes.
#
# Você deve ter recebido uma cópia da Licença Pública Geral GNU
# junto com este programa, se não, veja em <http://www.gnu.org/licenses/>
"""Controller handles routes starting with /RESOURCE_NAME.

Change this file's name and contents as appropriate to the
resources your app exposes to clients.

"""
from lib.bottle import Bottle, view, request, response, redirect, HTTPError
from ..models import code_store as cs
from . import project, get_project, project_visual_data, BRYTHON
__author__ = 'carlo'

bottle = Bottle(
)  # create another WSGI application for this controller and resource.
# debug(True) #  uncomment for verbose error logging. Do not use in production


@bottle.get('/')
@view('index')
@get_project
def home():
    """ Return User Selection at application root URL"""
    module = request.query.module
    # project = request.query.proj or "spy"
    module = "NOT FOUND: %s" % module.upper() if module else None
    # print("home project", project)
    tops, items = project_visual_data(project)
    return dict(project=project,
                result=items,
Ejemplo n.º 5
0
"""Main.py is the top level script.

Loads the Bottle framework and mounts controllers.  Also adds a custom error
handler.
"""
from lib import bottle
from lib.bottle import Bottle, redirect, request
# name and list your controllers here so their routes become accessible.
from server.controllers import main_controller, project_controller, code_controller
# Enable debugging, which gives us tracebacks
bottle.DEBUG = True

# Run the Bottle wsgi application. We don't need to call run() since our
# application is embedded within an App Engine WSGI application server.
appbottle = Bottle()

# Mount a new instance of bottle for each controller and URL prefix.
# appbottle.mount("/external/brython/Lib/site-packages", project_controller.bottle)
appbottle.mount("/<:re:.*>/_spy", code_controller.bottle)
appbottle.mount("superpython", project_controller.appbottle)

# Mount a new instance of bottle for each controller and URL prefix.
appbottle.mount("/main", main_controller.bottle)
appbottle.mount("/code", code_controller.bottle)
# bottle.mount("/pontos", pontos_controller.bottle)


@appbottle.get('/')
def home():
    """ Return Hello World at application root URL"""