Repository navigation
Listen on port 5151 by default in the web examples - #253
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
Our readmes now tell people to open the web examples on port 5151. The code didn't agree. Some examples used 5000, some 5001, one used 5100, and two just took Flask's default. This change makes every web example listen on 5151 unless you ask for something else.
What changed
Only the default port moves. Here's each example and readme:
flask run(5000)flask run --port 5151The JavaScript harness for the creator context page also uses localhost:5151 now, so it matches.
What stays the same
If an example read the
PORTenvironment variable before, it still does. Only the fallback is new. Our CI setsPORTto 8097 for cloud and 8098 for on-premise in device-detection/ci/run-integration-tests.ps1, and that keeps working as before.We left a few ports alone because they aren't ours to pick: the mock usage server in test_usage.py (5000), the mock update server (5689), and the test servers on port 0.
One gap remains. The on-premise User-Agent Client Hints example and both IP Intelligence web examples still don't read
PORT. That was true before this change too, and it's left for a separate piece of work.No library code changed, so there's no version bump.
Tests
The first commit, a56efa4, adds the tests on their own:
They parse each example's source with
ast. Nothing starts a server, and no key or data file is needed. Each one checks that the default is 5151. The device detection test also confirms that the three examples that readPORTstill read it. Against rc they should fail, since the defaults there are 5000, 5001, 5100, or nothing at all. The second commit, c2eaa51, makes the change.Runs
Two temporary branches add the workflow on top of each commit:
The red run failed, as it should. All 10 Build and Test jobs failed, across Ubuntu and Windows on Python 3.10 to 3.14. In the Ubuntu Python 3.12 job, the one failing test is the new test_creator_context_port.py, which found 5100 where it expects 5151. Every other test in that job passed.
The green run passed, with every job succeeding.
The tests haven't been run anywhere else.
Before you upgrade
Bookmarked an example at localhost:5000, 5001, or 5100? It'll now be at localhost:5151. If you'd rather keep your old port, set
PORTfor the examples that read it, or runflask run --port <port>.