Re: [flask] Configuring the Flask port with SERVER_NAME
- From:
- Max Countryman
- Date:
- 2011-11-15 @ 13:36
You could set the SERVER_NAME and then set a SERVER_PORT and then use
those constants when you run the app:
SERVER_NAME = 127.0.0.1
SERVER_PORT = 5001
…
app.run(SERVER_NAME, SERVER_PORT)
Assuming you're running your app outside of the config, you'd need to
import the app object and then call the config dictionary:
import app
app.run(app.config.get('SERVER_NAME'), app.config.get('SERVER_PORT'))
On Nov 15, 2011, at 2:05 AM, Geordan Rosario wrote:
> Hi,
>
> I'm trying to get the Flask server to run on a different port than the
> default of 5000. The docs say that SERVER_NAME can be updated in the
> config to change this, but it doesn't appear to do so, even though when
> I print out app.config the SERVER_NAME is being set correctly. Passing
> the port keyword arg to app.run() does work, however.
>
> How can I configure the port via the config dict?
>
> Thanks,
> -geordan
Re: [flask] Configuring the Flask port with SERVER_NAME
- From:
- Simon Sapin
- Date:
- 2011-11-15 @ 12:30
Le 15/11/2011 08:05, Geordan Rosario a écrit :
> How can I configure the port via the config dict?
Hi,
Do you mean the port for the development server that you start with
app.run() ? You can’t. The port number is a parameter to the run method,
it is never taken from the config.
However your own code can look in the config before calling app.run()
Regards,
--
Simon Sapin