Skip to content

Commit

Permalink
use flask standards for files
Browse files Browse the repository at this point in the history
  • Loading branch information
gtmanfred committed Nov 1, 2022
1 parent 8fd3624 commit 86deb38
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 27 deletions.
20 changes: 20 additions & 0 deletions examples/todo/todo/rebar.py → examples/todo/todo/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from flask import Flask
from flask_rebar import HeaderApiKeyAuthenticator
from marshmallow import fields, pre_dump, pre_load

from flask_rebar import (
Expand All @@ -25,3 +26,22 @@
swagger_generator=generator,
handlers="todo.handlers",
)


def create_app():
app = Flask(__name__)

authenticator = HeaderApiKeyAuthenticator(header="X-MyApp-Key")
# The HeaderApiKeyAuthenticator does super simple authentication, designed for
# service-to-service authentication inside of a protected network, by looking for a
# shared secret in the specified header. Here we define what that shared secret is.
authenticator.register_key(key="my-api-key")
registry.set_default_authenticator(authenticator=authenticator)

rebar.init_app(app=app)

return app


if __name__ == "__main__":
create_app().run()
24 changes: 0 additions & 24 deletions examples/todo/todo/app_init.py

This file was deleted.

4 changes: 2 additions & 2 deletions examples/todo/todo/handlers/todo_handlers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from todo.database import todo_id_sequence, todo_database
from todo.rebar import rebar
from todo.rebar import registry
from todo.app import rebar
from todo.app import registry
from todo.schemas import (
CreateTodoSchema,
GetTodoListSchema,
Expand Down
2 changes: 1 addition & 1 deletion tests/examples/test_todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def tearDownClass(cls):
sys.path = cls.old_path

def setUp(self):
from todo.app_init import create_app
from todo.app import create_app

self.app = create_app()

Expand Down

0 comments on commit 86deb38

Please sign in to comment.