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

provide default app name #159

Merged
merged 2 commits into from
Nov 19, 2016
Merged

provide default app name #159

merged 2 commits into from
Nov 19, 2016

Conversation

r0fls
Copy link
Contributor

@r0fls r0fls commented Nov 19, 2016

This allows instantiating the Sanic object without providing an app name:

from sanic import Sanic
from sanic.response import json

app = Sanic()

@app.route("/")
async def test(request):
    return json({"hello": "world"})

app.run(host="0.0.0.0", port=8000)

@@ -18,7 +18,10 @@


class Sanic:
def __init__(self, name, router=None, error_handler=None):
def __init__(self, name=None, router=None, error_handler=None):
if not name:
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to use if name is None or if isinstance(name, NoneType) to account for falsey like values like ''

@r0fls
Copy link
Contributor Author

r0fls commented Nov 19, 2016

@seemethere I can see an argument for that, yes. If someone wants the instance name to be an empty string, who am I to blame them. Updated.

@seemethere seemethere merged commit 879b9a4 into sanic-org:master Nov 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants