Example #1
0
                config.get("database"))
engine = create_engine(database_url, echo=config.get("debug"))

app = Bottle()
plugin = sqlalchemy.Plugin(
    engine,
    database.Base.metadata,
    keyword='db',
    create=True,
    commit=True,
    use_kwargs=False
)
app.install(plugin)

session_manager = PickleSession()
valid_user = authenticator(session_manager, login_url='/login')


# ===
# API
# ===
@app.route("/api/sensors",
           apply=valid_user())
def api_sensors(db):
    """Returns a list of all the available sensors.

    If no sensors are found, returns null"""
    sensors = db.query(database.Sensor).all()
    if sensors:
        sensors = [{"id": sensor.id,
                    "name": sensor.name,
Example #2
0
#!/usr/bin/python

import pymongo
import os
import bottle
import bottlesession
import topicDAO
#from bs4 import BeautifulSoup
from bottle import redirect
from uuid import uuid4
import datetime

session_manager = bottlesession.CookieSession()
valid_user = bottlesession.authenticator(session_manager)

@bottle.route('/static/<path:path>')
def static_files(path):
	return bottle.static_file(path,root='static')

@bottle.route('/')
def topic_index():
	print "Inside Home page"
	username=bottle.request.get_cookie('username')
	dt1=datetime.datetime.utcnow()
	print str(dt1)
	user_list.update_user_time(username,str(dt1))
	return bottle.template('index')

@bottle.route('/creditFill', method='GET')
def credit_get():
	print "inside credit fill get"
Example #3
0
from os import path, system
from glob import glob
import datetime
import json
from markdown import markdown
from bottle import Bottle, template, static_file, request, BaseTemplate, redirect, response, abort, error
from bottlesession import CookieSession, authenticator
from user import User

__version__ = "1.20180623 HK"
__author__ = 'Eric Gibert'
__license__ = 'MIT'

session_manager = CookieSession(
    cookie_expires=3600)  #  NOTE: you should specify a secret
valid_user = authenticator(session_manager)

http_view = Bottle()
BaseTemplate.defaults['login_logout'] = "Login"


@error(404)
def error404(error):
    return '404 error:<h2>%s</h2>' % error


def get_pwo():
    """Helper function: returns a PonicWatch Object based on the object type and id found in the form.
    Expected fields in the form (can be hidden if necessary):
    - pw_object_type: the class name
    - id: the PWO id, which is the key in the controller's pwo dictionaries
Example #4
0
import bottle
import bottlesession
from utils import Utils
from matrix import Matrix
from database import Database
from emotion import emotionspresent, emotionscount
from objectmatrice import matricepresent

MY_UTILITY = Utils()
MY_MATRIX = Matrix()
MY_DATABASE = Database()
LIST_FILTER = []

SESSION_MANAGER = bottlesession.PickleSession()
SESSION_MANAGER = bottlesession.CookieSession()
VALID_USER = bottlesession.authenticator(SESSION_MANAGER)


@route('/')
@route('/home')
@view('index')
def home():
    """
    Cette fonction nous renvoie vers la page home.
    """
    connected_user, connected_user_role = MY_UTILITY.verificationsession(
        'user')
    return dict(title='Accueil',
                user=connected_user,
                role=connected_user_role,
                year=MY_UTILITY.date.year)
Example #5
0
import time

# Project
import utils

# Bottle
from bottle import route, run, static_file, request, redirect, response
import bottlesession

USERS = {'test': 'testpassword'}
REQUIRELOGIN = False

session_manager = bottlesession.JSONSession()

if REQUIRELOGIN:
    authenticate = bottlesession.authenticator(session_manager,
                                               login_url='/_login')
else:
    authenticate = lambda: lambda b: b  # Wrapper that does nothing


@route('/_login', method=['get', 'post'])
@route('/_login/<path:path>', method=['get', 'post'])
def login(path=None):
    """
    Login. Use  @authenticate decorator for a given path
    or call this function with a path to redirect to that path
    """
    if path is None:  # for @authenticate decorator
        path = request.get_cookie('validuserloginredirect', '/')

    print('PATH', path)