def create_app(config=None): """ Create and initialise the application. """ app = Flask(__name__) app.config.from_pyfile('%s/config/default.py' % app.root_path) if config: app.config.from_pyfile(config) elif os.getenv('FLASK_CONFIG'): app.config.from_envvar('FLASK_CONFIG') logger.init(app) jinja.init(app) assets.init(app) app.register_blueprint(views.blueprint) @app.errorhandler(404) def not_found(error): return render_template('errors/404.html'), 404 @app.errorhandler(403) def forbidden(error): return render_template('errors/403.html'), 403 @app.errorhandler(500) def server_error(error): return render_template('errors/default.html'), 500 return app
def create_app(config=None): """ Create and initialise the application. """ app = Flask(__name__) app.config.from_pyfile('%s/config/default.py' % app.root_path) if config: app.config.from_pyfile(config) elif os.getenv('FLASK_CONFIG'): app.config.from_envvar('FLASK_CONFIG') logger.init(app) jinja.init(app) uploads.init(app) assets.init(app) # Add request hook to change x-sendfile to x-accel-redirect (for nginx) @request_finished.connect_via(app) def nginx_sendfile_patch(sender, response): if 'X-Sendfile' in response.headers: filepath = '/' + relpath( response.headers['X-Sendfile'], abspath(app.config['UPLOADS_DEFAULT_DEST'])) response.headers['X-Accel-Redirect'] = filepath del response.headers['X-Sendfile'] app.register_blueprint(views.blueprint) app.register_blueprint(api.blueprint) @app.errorhandler(404) def not_found(error): return render_template('errors/404.html'), 404 @app.errorhandler(403) def forbidden(error): return render_template('errors/403.html'), 403 @app.errorhandler(500) def server_error(error): return render_template('errors/default.html'), 500 return app
def create_app(config=None): """ Create and initialise the application. """ app = Flask(__name__) app.config.from_pyfile('%s/config/default.py' % app.root_path) if config: app.config.from_pyfile(config) elif os.getenv('FLASK_CONFIG'): app.config.from_envvar('FLASK_CONFIG') logger.init(app) jinja.init(app) uploads.init(app) assets.init(app) # Add request hook to change x-sendfile to x-accel-redirect (for nginx) @request_finished.connect_via(app) def nginx_sendfile_patch(sender, response): if 'X-Sendfile' in response.headers: filepath = '/' + relpath(response.headers['X-Sendfile'], abspath(app.config['UPLOADS_DEFAULT_DEST'])) response.headers['X-Accel-Redirect'] = filepath del response.headers['X-Sendfile'] app.register_blueprint(views.blueprint) app.register_blueprint(api.blueprint) @app.errorhandler(404) def not_found(error): return render_template('errors/404.html'), 404 @app.errorhandler(403) def forbidden(error): return render_template('errors/403.html'), 403 @app.errorhandler(500) def server_error(error): return render_template('errors/default.html'), 500 return app
DEBUG = True else: DEBUG = False BASE_URL = 'http://jeffgodwyll.com' FLATPAGES_AUTO_RELOAD = True FLATPAGES_EXTENSION = '.md' FLATPAGES_ROOT = 'pages' # App configuration FEED_MAX_LINKS = 25 SECTION_MAX_LINKS = 12 app = Flask(__name__) app.config.from_object(__name__) assets.init(app) pages = FlatPages(app) freezer = Freezer(app) markdown_manager = Markdown(app, extensions=['fenced_code'], output_format='html5',) # social profiles with open("./social.yaml", "r") as f: profiles = yaml.load(f.read()) SOCIAL_PROFILES = OrderedDict(sorted(profiles.items())) ############################################################################### # Model helpers
import pygame, assets from screen.title import TitleScreen from screen.exit import WussScreen pygame.font.init() size = width, height = 640, 480 screen = pygame.display.set_mode(size) pygame.display.set_caption("Super Extreme Tic-Tac-Toe") assets.init(screen) font = pygame.font.SysFont(assets.font, 16) white = pygame.Color("white") black = pygame.Color("black") clock = pygame.time.Clock() currentScreen = TitleScreen(screen) while 1: for event in pygame.event.get(): if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE): currentScreen = WussScreen(screen) currentScreen = currentScreen.event(event) currentScreen.logic() fps = font.render(str(int(clock.get_fps())) + " FPS", True, white, black) fps_rect = fps.get_rect() fps_rect.topright = (width, 0)
def create_app(config, debug=False, testing=False, config_overrides=None): app = Flask(__name__) app.config.from_object(config) app.debug = debug app.testing = testing assets.init(app) if config_overrides: app.config.update(config_overrides) # Configure logging if not app.testing: logging.basicConfig(level=logging.INFO) # Add a default root route. @app.route("/") def index(): return render_template('main.html') @app.route("/team") def team(): return render_template('team.html') @app.route("/request_sensor") def request_sensor(): return render_template('request_sensor.html') @app.route("/airu_sensor") def airu_sensor(): return render_template('airu_sensor.html') @app.route("/project") def project(): return render_template('project.html') @app.route("/newsroom") def newsroom(): return render_template('newsroom.html') @app.route("/mailinglist") def mailinglist(): return render_template('mailinglist.html') @app.route("/sensor_FAQ") def sensor_FAQ(): return render_template('sensor_FAQ.html') # Add an error handler. This is useful for debugging the live application, # however, you should disable the output of the exception for production # applications. @app.errorhandler(500) def server_error(e): return """ An internal error occurred: <pre>{}</pre> See logs for full stacktrace. """.format(e), 500 return app
import assets import display #import game_event surface = 0 display.init() assets.init() def on_render(): display.blit_surface(surface, 0, 0) # print surface display.flip() def main_func(): display.setvideomode(800, 600, False) display.setcaption('Example01') surface = assets.load_surface("background.png") print 'key number: ', surface # print surface