GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-36345: Include the code from Tools/scripts/serve.py for the wsgiref-base web server example by matrixise · Pull Request #12562 · python/cpython

Conversation

@matrixise

@matrixise matrixise commented Mar 26, 2019 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

In this PR, I include the code from Tools/scripts/serve.py file but I don't touch the code of the script, just keep it intact because it's not the role of this PR.

https://bugs.python.org/issue36345

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added the docs Documentation in the Doc dir label Mar 26, 2019
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Mar 26, 2019
@bedevere-bot bedevere-bot added the awaiting review label Mar 26, 2019
@matrixise

matrixise commented Mar 26, 2019

Copy link
Copy Markdown
Member Author

@vstinner feel free to review this PR. Thank you so much

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@matrixise
matrixise force-pushed the bpo-36345-part-3 branch from d176d16 to 30b5249 Compare March 26, 2019 14:13
@vstinner

vstinner commented Mar 26, 2019

Copy link
Copy Markdown
Member

make check suspicious html SPHINXOPTS="-q -W -j4" failed with the following error on Travis CI:

Warning, treated as error:
[whatsnew/changelog:28] ".. literalinclude:" found in ".. literalinclude::"

I'm not sure why literalinclude is seen as an error?

@JulienPalard: Any idea?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@matrixise

matrixise commented Apr 4, 2019

Copy link
Copy Markdown
Member Author

@JulienPalard @vstinner ?

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot added awaiting change review and removed awaiting review labels Apr 4, 2019
@bedevere-bot

bedevere-bot commented Apr 4, 2019

Copy link
Copy Markdown

Thanks for making the requested changes!

: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner reviewed Apr 8, 2019
View reviewed changes
Comment thread Doc/library/wsgiref.rst Outdated

@vstinner vstinner Apr 8, 2019

Copy link
Copy Markdown
Member

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.

Can you explain what the server does? It seems like it serves the directory passed as the first argument on the command line, and accept an optional port number as the second parameter. Proposition:

"Example of a WSGI application serving the directory passed on the command line:"

By the way, would it make sense to modify the example of use the current directory by default, rather than require to pass a directory?

    path = sys.argv[1] if len(sys.argv) > 1 else os.getcwd()

with:

"Example of a WSGI application serving the current directory, accept optional directory and port number on the command line:"

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@matrixise

matrixise commented Apr 15, 2019 via email

Copy link
Copy Markdown
Member Author
By the way, would it make sense to modify the example of use the current directory by default, rather than require to pass a directory? ``` path = sys.argv[1] if len(sys.argv) > 1 else os.getcwd() ``` with: "Example of a WSGI application serving the current directory, accept optional directory and port number on the command line:"
I am fine with the optional directory, and because it's an example, it's not a problem, we don't break the backward compatibility. +1
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

matrixise added 4 commits April 15, 2019 13:53
@matrixise
bpo-36345: Include the code from Tools/scripts/serve.py for the wsgir…
756332d
…ef-base web server example
@matrixise
Fix the blurb entry
74fd34c
@matrixise
Example of a WSGI application serving the current directory, accept
c938813
optional directory and port number on the command line.
@matrixise
Update the description of the example
a3dbd35
@matrixise
matrixise force-pushed the bpo-36345-part-3 branch from 8d3c270 to a3dbd35 Compare April 15, 2019 12:23
@matrixise

matrixise commented Apr 15, 2019

Copy link
Copy Markdown
Member Author

I have made the requested changes; please review again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented Apr 15, 2019

Copy link
Copy Markdown

Thanks for making the requested changes!

: please review the changes made to this pull request.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner reviewed Apr 15, 2019
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

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.

When I tested the example, it wasn't obvious to me how to access the server.

Maybe the script should display somehow the URL http://localhost:8000/?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Tools/scripts/serve.py
path = sys.argv[1] if len(sys.argv) > 1 else os.getcwd()
port = int(sys.argv[2]) if len(sys.argv) > 2 else 8000
httpd = simple_server.make_server('', port, app)
print("Serving {} on port {}, control-C to stop".format(path, port))

@vstinner vstinner Apr 15, 2019

Copy link
Copy Markdown
Member

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.

When I press CTRL+C, I get a ResourceWarning. Please add httpd.server_close() after print("\b\bShutting down."). By the way, I'm not sure that "\b" is supported on Windows. I suggest to remove ""\b\b" to make the script more portable.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@matrixise matrixise Apr 15, 2019

Copy link
Copy Markdown
Member Author

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.

Fixed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/library/wsgiref.rst Outdated
# Serve until process is killed
httpd.serve_forever()
Example of a WSGI application serving the current directory, accept optional
directory and port number on the command line:

@vstinner vstinner Apr 15, 2019

Copy link
Copy Markdown
Member

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.

Suggested change
directory and port number on the command line:
directory and port number (default: 8000) on the command line:

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@matrixise

matrixise commented Apr 15, 2019 via email

Copy link
Copy Markdown
Member Author
When I tested the example, it wasn't obvious to me how to access the server.
Yep, it's the default output of `Tools/scripts/serve.py`
Maybe the script should display somehow the URL http://localhost:8000/?
Like the output of python -m http.server -d DIRECTORY? I propose to submit an other bpo issue/pull request where we suggest to change the default output of the `Tools/scripts/serve.py` What do you think?
> @@ -25,7 +25,7 @@ def app(environ, respond): return [b'not found'] if __name__ == '__main__': - path = sys.argv[1] + path = sys.argv[1] if len(sys.argv) > 1 else os.getcwd() port = int(sys.argv[2]) if len(sys.argv) > 2 else 8000 httpd = simple_server.make_server('', port, app) print("Serving {} on port {}, control-C to stop".format(path, port)) When I press CTRL+C, I get a ResourceWarning. Please add httpd.server_close() after print("\b\bShutting down."). By the way, I'm not sure that "\b" is supported on Windows. I suggest to remove "\b\b" to make the script more portable.
👍
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

matrixise added 3 commits April 15, 2019 21:38
@matrixise
Add the default port in the doc
530ed32
@matrixise
Close the resources for the httpd server
2b1fa72
@matrixise
Remove \b\b for the portability
a7db659
vstinner
vstinner approved these changes Apr 15, 2019
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

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.

LGTM. You can merge it once you will be able to merge changes ;-)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting change review labels Apr 15, 2019
@matrixise
matrixise merged commit 2b7f93b into python:master Apr 16, 2019
@bedevere-bot bedevere-bot removed the awaiting merge label Apr 16, 2019
@matrixise
matrixise deleted the bpo-36345-part-3 branch April 16, 2019 12:57
berkerpeksag
berkerpeksag reviewed Apr 16, 2019
View reviewed changes

@berkerpeksag berkerpeksag left a comment

Copy link
Copy Markdown
Member

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.

Two things:

  1. Only big documentation changes require a NEWS entry.
  2. We only attribute contributors in NEWS entries. It's OK to add your name to Doc/whatsnew/X.Y.rst even if you're a core developer, though.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner

vstinner commented Apr 16, 2019

Copy link
Copy Markdown
Member

Only big documentation changes require a NEWS entry.

I'm wasn't sure on that point. In case of doubt, I said nothing :-)

We only attribute contributors in NEWS entries. It's OK to add your name to Doc/whatsnew/X.Y.rst even if you're a core developer, though.

Well, Stéphane wrote this PR before he was a core dev :-)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@matrixise

matrixise commented Apr 16, 2019

Copy link
Copy Markdown
Member Author

@berkerpeksag Thank you for your advice, which I will use next time.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@berkerpeksag

berkerpeksag commented Apr 16, 2019

Copy link
Copy Markdown
Member

Well, Stéphane wrote this PR before he was a core dev :-)

I'm not sure how that is an argument here? It could be easily noticed and fixed before merging the PR.

@matrixise welcome!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@matrixise matrixise mentioned this pull request Apr 10, 2022
Doc: make serve uses http.server instead of Tools/scripts/server.py #80526
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@berkerpeksag berkerpeksag berkerpeksag left review comments
@vstinner vstinner vstinner approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

docs Documentation in the Doc dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@matrixise @vstinner @bedevere-bot @berkerpeksag @the-knights-who-say-ni
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.