Skip to content

Instantly share code, notes, and snippets.

@jacobh
Created October 9, 2011 17:42
Show Gist options
  • Save jacobh/1273948 to your computer and use it in GitHub Desktop.
Save jacobh/1273948 to your computer and use it in GitHub Desktop.
bottle includes
Traceback (most recent call last):
File "main.py", line 24, in <module>
app.mount('/static/', default_views)
File "/usr/local/lib/python2.6/dist-packages/bottle.py", line 430, in mount
raise TypeError('Only Bottle instances are supported for now.')
TypeError: Only Bottle instances are supported for now.
# library includes
from bottle import *
from beaker.middleware import SessionMiddleware
# importing my files
import db
import settings
import functions
# setting up the app and the sessions
app = default_app()
session_opts = {
'session.lock_dir': '.',
'session.type': 'ext:database',
'session.url': settings.db_url,
'session.auto': True,
'session.table_name': 'cpanel_sessions',
}
# views
import views
# mount
mount('/static/', views.app)
mount('/', views.app)
mount('/dashboard/', views.app)
mount('/login/', views.app)
#let's run this
app = SessionMiddleware(app, session_opts)
debug(True)
run(app=app, reloader=True)
import bottle
app = bottle.app()
# routes for static files
@app.get('/static/:path#.+#')
def serve_static(path):
return static_file(path, root='static')
@app.get('/')
def home():
if functions.Check_auth(request) == True:
redirect('/dashboard/')
else:
redirect('/login/')
@app.get('/dashboard/')
def view_dasboard():
c = {
'page_title': settings.site_title + ' / Dashboard'
}
return functions.Template('dashboard', c).render()
@app.get('/login/')
def login_form():
t = functions.Template('login')
return t.render()
@app.post('/login/')
def do_login():
user = functions.Check_login(request.POST['username'], request.POST['password'])
if user != False:
session = request.environ.get('beaker.session')
session['logged_in'] = True
session['steamid'] = user.steamid
return 'auth success!'
else:
return 'auth fail :('
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment