-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Implement web.run_app utility function #734
Changes from 1 commit
636b075
0b8e831
918d820
7670eee
2e4e4bb
479e151
6f35b4d
c9b74c8
6b5ed62
51267fb
a2b39a0
df0cb02
1b7f94c
0f17dca
635599c
727393b
69d30c0
8460828
f418dca
0733de2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- v4.0.0a1
- v4.0.0a0
- v3.11.14
- v3.11.13
- v3.11.12
- v3.11.11
- v3.11.10
- v3.11.9
- v3.11.8
- v3.11.7
- v3.11.6
- v3.11.5
- v3.11.4
- v3.11.3
- v3.11.2
- v3.11.1
- v3.11.0
- v3.11.0rc2
- v3.11.0rc1
- v3.11.0rc0
- v3.11.0b5
- v3.11.0b4
- v3.11.0b3
- v3.11.0b2
- v3.11.0b1
- v3.11.0b0
- v3.10.11
- v3.10.11rc0
- v3.10.10
- v3.10.9
- v3.10.8
- v3.10.7
- v3.10.6
- v3.10.6rc2
- v3.10.6rc1
- v3.10.6rc0
- v3.10.5
- v3.10.4
- v3.10.3
- v3.10.2
- v3.10.1
- v3.10.0
- v3.10.0rc0
- v3.10.0b1
- v3.10.0b0
- v3.9.5
- v3.9.4
- v3.9.4rc0
- v3.9.3
- v3.9.2
- v3.9.1
- v3.9.0
- v3.9.0rc0
- v3.9.0b1
- v3.9.0b0
- v3.8.6
- v3.8.5
- v3.8.4
- v3.8.3
- v3.8.2
- v3.8.2a0
- v3.8.1
- v3.8.0
- v3.8.0b0
- v3.8.0a7
- v3.8.0a6
- v3.8.0a5
- v3.8.0a4
- v3.8.0a3
- v3.8.0a2
- v3.8.0a1
- v3.8.0a0
- v3.7.4
- v3.7.4.post0
- v3.7.3
- v3.7.2
- v3.7.1
- v3.7.0
- v3.7.0b1
- v3.7.0b0
- v3.6.3
- v3.6.2
- v3.6.2a2
- v3.6.2a1
- v3.6.2a0
- v3.6.1
- v3.6.1b4
- v3.6.1b3
- v3.6.0
- v3.6.0b0
- v3.6.0a12
- v3.6.0a11
- v3.6.0a10
- v3.6.0a9
- v3.6.0a8
- v3.6.0a7
- v3.6.0a6
- v3.6.0a5
- v3.6.0a4
- v3.6.0a3
- v3.6.0a2
- v3.6.0a1
- v3.6.0a0
- v3.5.4
- v3.5.3
- v3.5.2
- v3.5.1
- v3.5.0
- v3.5.0b3
- v3.5.0b2
- v3.5.0b1
- v3.5.0a1
- v3.4.4
- v3.4.3
- v3.4.2
- v3.4.1
- v3.4.0
- v3.4.0b2
- v3.4.0b1
- v3.4.0a3
- v3.4.0a2
- v3.4.0a1
- v3.4.0a0
- v3.3.2
- v3.3.2a0
- v3.3.1
- v3.3.1b1
- v3.3.0
- v3.2.1
- v3.2.0
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.9
- v3.0.8
- v3.0.7
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v3.0.0b4
- v3.0.0b3
- v3.0.0b2
- v3.0.0b1
- v3.0.0b0
- v2.3.10
- v2.3.9
- v2.3.8
- v2.3.7
- v2.3.6
- v2.3.5
- v2.3.4
- v2.3.3
- v2.3.2
- v2.3.2b3
- v2.3.2b2
- v2.3.2b1
- v2.3.1
- v2.3.1a1
- v2.3.0
- v2.3.0a4
- v2.3.0a3
- v2.3.0a2
- v2.3.0a1
- v2.2.5
- v2.2.4
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.0
- v1.2.0
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.5
- v1.0.4
- v1.0.2
- v1.0.1
- v1.0.0
- v0.22.5
- v0.22.4
- v0.22.3
- v0.22.2
- v0.22.1
- v0.22.0
- v0.22.0b6
- v0.22.0b5
- v0.22.0b4
- v0.22.0b3
- v0.22.0b2
- v0.22.0b1
- v0.22.0b0
- v0.21.6
- v0.21.5
- v0.21.4
- v0.21.3
- v0.21.2
- v0.21.1
- v0.21.0
- 4v0.21.6
- 3.3.0a0
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.3-1
- 2.0.2
- 2.0.1
- 2.0.0
- 2.0.0rc1
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -273,22 +273,26 @@ def __repr__(self): | |
|
||
|
||
def run_app(app, *, host='0.0.0.0', port=None, loop=None, | ||
shutdown_timeout=60.0): | ||
shutdown_timeout=60.0, ssl_context=None): | ||
"""Run an app locally""" | ||
if port is None: | ||
# allow to use 8443 if future ssl=True will be added | ||
port = 8080 | ||
if not ssl_context: | ||
port = 8080 | ||
else: | ||
port = 8443 | ||
|
||
if loop is None: | ||
loop = asyncio.get_event_loop() | ||
|
||
handler = app.make_handler() | ||
srv = loop.run_until_complete(loop.create_server(handler, host, port)) | ||
srv = loop.run_until_complete(loop.create_server(handler, host, port, | ||
ssl=ssl_context)) | ||
|
||
scheme = 'https' if ssl_context else 'http' | ||
prompt = '127.0.0.1' if host == '0.0.0.0' else host | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How should someone bind to public interface? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, read from end to top)) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I don't follow. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I already said -- I read diff from bottom to top) thought that you replaced '0.0.0.0' with localhost and bind to it) |
||
print(" * Running on http://{prompt}:{port}/ \n" | ||
print("======== Running on {scheme}://{prompt}:{port}/ ========\n" | ||
"(Press CTRL+C to quit)".format( | ||
host=prompt, port=port)) | ||
scheme=scheme, host=prompt, port=port)) | ||
|
||
try: | ||
loop.run_forever() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is an explicit
loop
parameter necessary -- Wouldn'tloop = app.loop
suffice here?Is there a use case where the App would run on a different loop than the Server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!