Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Adds support for passing in a name and a Flask application to the ini… #82

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions firefly/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .version import __version__
import threading
from wsgiref.simple_server import make_server
from flask import Flask

try:
from inspect import signature, _empty
Expand All @@ -25,7 +26,7 @@
ctx.request = None

class Firefly(object):
def __init__(self, auth_token=None, allowed_origins=""):
def __init__(self, name="firefly", auth_token=None, allowed_origins="", flask_app=None):
"""Creates a firefly application.

If the optional parameter auth_token is specified, the
Expand All @@ -39,11 +40,12 @@ def __init__(self, auth_token=None, allowed_origins=""):
:param auth_token: the auto_token for the application
:param allowed_origins: allowed origins for cross-origin requests
"""
self.name = name
self.mapping = {}
self.add_route('/', self.generate_index,internal=True)
self.auth_token = auth_token
self.allowed_origins = allowed_origins

self.flask_app = flask_app or Flask(name)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally it should be,
self.flask_app = flask_app if flask_app else Flask(name) as this is more readable.

The current statement also evaluates to the same result, however intent is not clear, and one has to know that Python evaluates or lazily.


def set_auth_token(self, token):
self.auth_token = token
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ WebOb>=1.7.2
requests>=2.18.1
PyYAML>=3.12
funcsigs>=1.0.2 ; python_version < '3'
Flask==1.0.2