Example #1
0
def post():
    response.content_type = "text/html; charset=UTF-8"
    sess = session()
    sess.set("ime", request.POST.ime)  # request.POST["ime"] ne deluje pravilno
    sess.set("spol", request.POST.spol)  # s šumniki v Python3!
    sess.close()
    redirect("/")
Example #2
0
def post():
    response.content_type = "text/html; charset=UTF-8"
    sess = session()
    sess.set("ime", request.POST.ime) # request.POST["ime"] ne deluje pravilno
    sess.set("spol", request.POST.spol) # s šumniki v Python3!
    sess.close()
    redirect("/")
Example #3
0
def index():
    response.content_type = "text/html; charset=UTF-8"
    sess = session()
    try:
        ime = sess.read("ime")
        spol = sess.read("spol")
        pozdrav = "Pozdravljen%s %s!" % ("a" if spol == "zenska" else "", ime)
    except:
        ime = ""
        spol = ""
        pozdrav = "Tebe pa ne poznam!"
    moski = "checked" if spol == "moski" else ""
    zenska = "checked" if spol == "zenska" else ""
    sess.close()
    return template("index.html", pozdrav=pozdrav, ime=ime, moski=moski, zenska=zenska)
Example #4
0
def index():
    response.content_type = "text/html; charset=UTF-8"
    sess = session()
    try:
        ime = sess.read("ime")
        spol = sess.read("spol")
        pozdrav = "Pozdravljen%s %s!" % ("a" if spol == "zenska" else "", ime)
    except:
        ime = ""
        spol = ""
        pozdrav = "Tebe pa ne poznam!"
    moski = "checked" if spol == "moski" else ""
    zenska = "checked" if spol == "zenska" else ""
    sess.close()
    return template("index.html",
                    pozdrav=pozdrav,
                    ime=ime,
                    moski=moski,
                    zenska=zenska)
Example #5
0
from bottle import error, request, route, run, get, post, put, delete, static_file
from bottlesession import session
import json
from ScriplerMongoDB import ScriplerMongoDB
from MongoJSONEncoder import MongoJSONEncoder
import hashlib

db = ScriplerMongoDB()
        
def toJSON(cursor):
    return json.dumps(cursor, cls=MongoJSONEncoder)

sess = session()

@error(500)
def custom500(error):
    return 'Scripler failed: %s' % str(error.exception)
 
@route('/static/<filename>')
def callback(filename):
    return static_file(filename, './static/')
 
@get('/')
def api_root():
    return static_file("index.html", './static/')

@post('/login')
def api_login():
    user = db.getUserByUsername(request.json['username'])
    ret = None
    if user != None and user["passwordHash"] == hashlib.sha256(request.json['password']).hexdigest():
Example #6
0
from bottle import *
from bottlesession import session
import modeli

#!/usr/bin/python
# -*- coding: utf-8 -*-

seja = session()
seja.set('vpisani_ime', 'gost')
seja.set('vpisani_ID', '')


def dodajanje_v_kosarico(knjiga, kupec):
    '''Doda knjigo v kosarico, ce je na zalogi.'''
    if modeli.na_zalogi(knjiga):
        modeli.dodaj_v_kosarico(knjiga, kupec)
        redirect('/stran_za_kupca/moja_kosarica')
    else:
        return "Knjige trenutno ni na zalogi.<br><br>" +\
               "<a href=\"/stran_za_kupca\">Nazaj v knjigarno</a>"


##--> DOMAČA STRAN <--##
@route('/')
def domaca_stran():
    return template(
        'domaca_stran',
        kupec=modeli.seznam_knjig_kupec(),
        knjigarnar=modeli.seznam_knjig_knjigarnar(),
    )