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

flask run provides no way to have a port configured by default #2661

Closed
antialiasis opened this issue Mar 17, 2018 · 2 comments
Closed

flask run provides no way to have a port configured by default #2661

antialiasis opened this issue Mar 17, 2018 · 2 comments
Milestone

Comments

@antialiasis
Copy link

I have a number of sites that I may be working on simultaneously, and to facilitate this I've arbitrarily designated a particular port that I run each site on in development, rather than running on the default port. I used to do this by having each project specify a hardcoded port when it called app.run:

app.run(debug=True, port=8050)

With Flask 0.12, the recommended way to run Flask is using the flask run command, which seems like a good change overall. In each application's virtualenv setup, I can set the FLASK_APP and FLASK_DEBUG environment variables so that I don't have to set them manually every time I start up the development server. However, there is no environment variable or anything of the sort to set the port, so every time I run an application, I still need to manually specify the appropriate port each time - flask run --port 8050 instead of just flask run.

In #2113 joelhed wanted to use the port in the SERVER_NAME config variable, and the issue was closed on the basis that it's technically infeasible to load app config before starting up the server, which makes sense. However, a FLASK_PORT environment variable would presumably not have this problem, and it would reduce friction significantly both for people like me and joelhed (and anyone else who for any reason can't run all their Flask applications on port 5000). Is there any chance for this to be added? I can make a pull request for this if necessary.

@davidism
Copy link
Member

Click already sets options using env vars: export FLASK_RUN_PORT=8050

@davidism
Copy link
Member

Turns out this wasn't documented, I thought it was. See #2713.

@davidism davidism added this to the 1.0 milestone Apr 20, 2018
@pallets pallets deleted a comment from seemsindie Feb 20, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants