예제 #1
0
def get_pg_installed_app():
    app = Bottle()
    plugin = bottle_pgsql.Plugin('dbname={} user={} password={}'.format(
        DB_NAME, DB_USER, DB_PASS))
    app.install(plugin)
    app.route('/<:re:.*>', method='OPTIONS', callback=enableCORSGenericRoute)
    app.add_hook("after_request", enableCORSGenericRoute)
    return app
예제 #2
0
app = bottle.default_app()


@hook('before_request')
def setup_request():
    request.session = request.environ['beaker.session']


for l in utils.allowed_languages:
    app.mount('/' + l, app)

from bottle import SimpleTemplate
SimpleTemplate.defaults["get_url"] = app.get_url

import bottle_pgsql
app.install(bottle_pgsql.Plugin(utils.db_string))
import bottle_gettext, os
app.install(
    bottle_gettext.Plugin('osmose-frontend', os.path.join("po", "mo"),
                          utils.allowed_languages))


def ext_filter(config):
    regexp = r'html|json|xml|rss|png|svg|pdf|gpx|josm'

    def to_python(match):
        return match if match in ('html', 'json', 'xml', 'rss', 'png', 'svg',
                                  'pdf', 'gpx', 'josm') else 'html'

    def to_url(ext):
        return ext
예제 #3
0
파일: server.py 프로젝트: simmbabyface/ita
from bottle import HTTPError, request, response, run, Bottle, static_file, redirect
# from datetime import datetime, timedelta
from command_line2 import input_mapping
from start_prediction import input_mapping_prediction

# logging.config.dictConfig(json.load(open('logging.json', 'rb')))


def datetime_handler(x):
    if isinstance(x, datetime.datetime):
        return x.isoformat()
    raise TypeError("Unknown type")


app = Bottle()
plugin = bottle_pgsql.Plugin(
    'dbname=ita user=babyface password=5555 host=localhost port=5432')
app.install(plugin)


@app.get('/sample')
def sample_redirect():
    redirect('/#sample')


@app.get('/chemical')
def chemical_redirect():
    redirect('/#chemical')


@app.get('/assay')
def chemical_redirect():
예제 #4
0
# User API tokens
toggl_token = "6673bce594aba392f5d9a5f87660f626"
fl_token = 'md0o5M70M7nWNPP2DpMLk9yQlV8gYv'

# DB connection
conn = psycopg2.connect(dbname='postgres',
                        user='******',
                        password='******',
                        host='localhost',
                        port='5432')
cursor = conn.cursor()

# Bottle DB connection
app = bottle.Bottle()
plugin = bottle_pgsql.Plugin(
    'dbname=postgres user=postgres password=admin host=localhost port=5432')
app.install(plugin)


class User:
    def __init__(self, toggl_token, fl_token):
        self.toggl_token = toggl_token
        self.fl_token = fl_token

    def get_toggle_user(self):
        url = "https://www.toggl.com/api/v8/me"
        response = requests.get(url, auth=(self.toggl_token, 'api_token'))
        user_info = json.loads(response.text)

        self.toggl_id, self.toggl_email = str(
            user_info['data']['id']), user_info['data']['email']
예제 #5
0
from jinja2 import Template
#from weasyprint import HTML
import pdfkit

from django.core.serializers.json import DjangoJSONEncoder
from DatabaseConfigurations import Configs
import base64
import time
from time import mktime
from fpdf import FPDF, HTMLMixin
from datetime import datetime

app = bottle.Bottle()
configuration = Configs.Config('configuracoes.cfg')
plugin = bottle_pgsql.Plugin('host=192.168.160.120 ' + 'dbname=' +
                             configuration.connStringDB() + ' user='******' password='******'dbname=' + configuration.connStringDB() + ' user='******' host=' +
                        configuration.connStringHost() + ' password='******'/docs/<filename:re:.*>')
def html(filename):
    return static_file(filename, root='../')


@app.error(404)
def error404(error):