コード例 #1
0
ファイル: bombolone.py プロジェクト: andreasacca/bombolone
def type_thing(context, key):
    return type(key)
	
def len_thing(context, key):
    return len(key)
	
def enumerate_thing(context, key):
    return enumerate(key)

# add some functions to jinja
app.jinja_env.globals['sorted'] = contextfunction(sorted_thing)  
app.jinja_env.globals['int'] = contextfunction(int_thing)   
app.jinja_env.globals['str'] = contextfunction(str_thing) 
app.jinja_env.globals['unicode'] = contextfunction(unicode_thing) 
app.jinja_env.globals['type'] = contextfunction(type_thing) 
app.jinja_env.globals['len'] = contextfunction(len_thing) 
app.jinja_env.globals['enumerate'] = contextfunction(enumerate_thing) 

class RegexConverter(BaseConverter):
    def __init__(self, url_map, *items):
        super(RegexConverter, self).__init__(url_map)
        self.regex = items[0]

# regular expressions inside url routing
app.url_map.converters['regex'] = RegexConverter

for module in LIST_MODULES:
    app.register_blueprint(module)
    
if __name__ == '__main__':
    app.run(host='0.0.0.0', port=PORT)
コード例 #2
0
ファイル: app.py プロジェクト: DangerOnTheRanger/maniwani
from flask import render_template, send_from_directory

from blueprints.boards import boards_blueprint
from blueprints.main import main_blueprint
from blueprints.slip import slip_blueprint
from blueprints.theme import theme_blueprint
from blueprints.threads import threads_blueprint
from blueprints.upload import upload_blueprint
from blueprints.live import live_blueprint
from resources import (BoardCatalogResource, BoardListResource,
                       FirehoseResource, NewPostResource, NewThreadResource,
                       PostRemovalResource, ThreadPostsResource,
                       SinglePostResource)
from shared import app, rest_api

app.register_blueprint(main_blueprint, url_prefix="/")
app.register_blueprint(boards_blueprint, url_prefix="/boards")
app.register_blueprint(theme_blueprint, url_prefix="/theme")
app.register_blueprint(threads_blueprint, url_prefix="/threads")
app.register_blueprint(upload_blueprint, url_prefix="/upload")
app.register_blueprint(slip_blueprint, url_prefix="/slip")
if app.config["SERVE_STATIC"]:
    app.register_blueprint(slip_blueprint, url_prefix="/static")

if app.config["SERVE_REST"]:
    rest_api.add_resource(BoardListResource, "/api/v1/boards/")
    rest_api.add_resource(BoardCatalogResource,
                          "/api/v1/board/<int:board_id>/catalog")
    rest_api.add_resource(ThreadPostsResource,
                          "/api/v1/thread/<int:thread_id>")
    rest_api.add_resource(NewThreadResource, "/api/v1/thread/new")
コード例 #3
0
from shared import app, db

from polling_app.views import polling as p

app.register_blueprint(p)
# from views import *
from polling_app.models import User, Question, Choice, Answer

if __name__ == '__main__':
    # recreate tables and insert 2 default users
    db.drop_all()
    db.create_all()
    db.session.commit()

    u1 = User(username='******')
    u2 = User(username='******')
    db.session.add_all([u1, u2])
    db.session.commit()

    app.run()
コード例 #4
0
    return value


# add some functions to jinja
app.jinja_env.globals['sorted'] = contextfunction(sorted_thing)
app.jinja_env.globals['int'] = contextfunction(int_thing)
app.jinja_env.globals['str'] = contextfunction(str_thing)
app.jinja_env.globals['unicode'] = contextfunction(unicode_thing)
app.jinja_env.globals['type'] = contextfunction(type_thing)
app.jinja_env.globals['len'] = contextfunction(len_thing)
app.jinja_env.globals['enumerate'] = contextfunction(enumerate_thing)

app.jinja_env.filters['date'] = date_time_format
app.jinja_env.filters['split_word'] = split_word_format
app.jinja_env.filters['msg'] = msg_status


class RegexConverter(BaseConverter):
    def __init__(self, url_map, *items):
        super(RegexConverter, self).__init__(url_map)
        self.regex = items[0]


# regular expressions inside url routing
app.url_map.converters['regex'] = RegexConverter

for module in LIST_MODULES:
    app.register_blueprint(module)

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=PORT)
コード例 #5
0
from blueprints.boards import boards_blueprint
from blueprints.main import main_blueprint
from blueprints.slip import slip_blueprint
from blueprints.threads import threads_blueprint
from blueprints.upload import upload_blueprint
from model.BoardCatalogResource import BoardCatalogResource
from model.BoardListResource import BoardListResource
from model.FirehoseResource import FirehoseResource
from model.NewPostResource import NewPostResource
from model.NewThreadResource import NewThreadResource
from model.PostRemovalResource import PostRemovalResource
from model.ThreadPostsResource import ThreadPostsResource
from shared import app, rest_api

app.register_blueprint(main_blueprint, url_prefix='/')
app.register_blueprint(boards_blueprint, url_prefix='/boards')
app.register_blueprint(threads_blueprint, url_prefix='/threads')
app.register_blueprint(upload_blueprint, url_prefix='/upload')
app.register_blueprint(slip_blueprint, url_prefix='/slip')

rest_api.add_resource(BoardListResource, "/api/v1/boards/")
rest_api.add_resource(BoardCatalogResource,
                      "/api/v1/board/<int:board_id>/catalog")
rest_api.add_resource(ThreadPostsResource, "/api/v1/thread/<int:thread_id>")
rest_api.add_resource(NewThreadResource, "/api/v1/thread/new")
rest_api.add_resource(PostRemovalResource, "/api/v1/thread/post/<int:post_id>")
rest_api.add_resource(NewPostResource, "/api/v1/thread/<int:thread_id>/new")
rest_api.add_resource(FirehoseResource, "/api/v1/firehose")