Julio Biason
11 years ago
10 changed files with 120 additions and 1 deletions
Binary file not shown.
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env python |
||||
# -*- encoding: utf-8 -*- |
||||
|
||||
|
Binary file not shown.
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python |
||||
# -*- encoding: utf-8 -*- |
||||
|
||||
"""The index blueprint. There is nothing here, we just show a summary of |
||||
the current API requests.""" |
||||
|
||||
from operator import itemgetter |
||||
|
||||
from flask import Blueprint |
||||
from flask import jsonify |
||||
from flask import current_app |
||||
|
||||
index = Blueprint('index', __name__) |
||||
|
||||
@index.route('') |
||||
def show_routes(): |
||||
"""List the current API""" |
||||
routes = [] |
||||
for rule in current_app.url_map.iter_rules(): |
||||
endpoint = rule.endpoint |
||||
if endpoint == 'static': |
||||
continue |
||||
|
||||
path = str(rule) |
||||
methods = rule.methods |
||||
doc = current_app.view_functions[endpoint].__doc__ |
||||
|
||||
routes.append([ |
||||
path, |
||||
doc |
||||
]) |
||||
|
||||
routes.sort(key=itemgetter(0)) |
||||
return jsonify(routes) |
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python |
||||
# -*- encoding: utf-8 -*- |
||||
|
||||
import datetime |
||||
|
||||
from pony.orm import Database |
||||
from pony.orm import PrimaryKey |
||||
from pony.orm import Optional |
||||
from pony.orm import Required |
||||
# from pony.orm import Set |
||||
|
||||
db = Database("sqlite", "tagallery.db", create_db=True) |
||||
|
||||
class User(db.Entity): |
||||
"""Users.""" |
||||
username = PrimaryKey(unicode) |
||||
passhash = Required(unicode) |
||||
token = Optional(unicode) # 1. if the user never logged in, they will |
||||
# not have a token. |
||||
# 2. This forces the user to have a single |
||||
# login everywhere, per day. |
||||
issue_date = Optional(datetime.datetime) |
||||
|
||||
db.generate_mapping(create_tables=True) |
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python |
||||
# -*- encoding: utf-8 -*- |
||||
|
||||
import sys |
||||
|
||||
from flask import Flask |
||||
|
||||
# ---------------------------------------------------------------------- |
||||
# Config |
||||
# ---------------------------------------------------------------------- |
||||
SQLITE_FILENAME = './luncho.db3' |
||||
|
||||
# ---------------------------------------------------------------------- |
||||
# Load the config |
||||
# ---------------------------------------------------------------------- |
||||
app = Flask(__name__) |
||||
app.config.from_object(__name__) |
||||
app.config.from_envvar('LUCNHO_CONFIG', True) |
||||
|
||||
# ---------------------------------------------------------------------- |
||||
# Blueprints |
||||
# ---------------------------------------------------------------------- |
||||
from blueprints.index import index |
||||
|
||||
app.register_blueprint(index, url_prefix='/') |
||||
|
||||
# ---------------------------------------------------------------------- |
||||
# Database |
||||
# ---------------------------------------------------------------------- |
||||
from pony.orm import db_session |
||||
app.wsgi_app = db_session(app.wsgi_app) |
||||
|
||||
# ---------------------------------------------------------------------- |
||||
# Main |
||||
# ---------------------------------------------------------------------- |
||||
if __name__ == '__main__': |
||||
log.warning('Use manage.py to run the server.') |
||||
sys.exit(1) |
||||
|
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env python |
||||
# -*- encoding: utf-8 -*- |
||||
|
||||
import logging |
||||
|
||||
from flask.ext.script import Manager |
||||
|
||||
from luncho.server import app |
||||
|
||||
manager = Manager(app) |
||||
|
||||
if __name__ == '__main__': |
||||
logging.basicConfig(level=logging.DEBUG) |
||||
manager.run() |
Loading…
Reference in new issue