Configure Flask dev server to be visible across the network

前端 未结 14 2429
面向向阳花
面向向阳花 2020-11-21 05:57

I\'m not sure if this is Flask specific, but when I run an app in dev mode (http://localhost:5000), I cannot access it from other machines on the network (with

14条回答
  •  情话喂你
    2020-11-21 06:51

    Create file .flaskenv in the project root directory.

    The parameters in this file are typically:

    FLASK_APP=app.py
    FLASK_ENV=development
    FLASK_RUN_HOST=[dev-host-ip]
    FLASK_RUN_PORT=5000
    

    If you have a virtual environment, activate it and do a pip install python-dotenv .

    This package is going to use the .flaskenv file, and declarations inside it will be automatically imported across terminal sessions.

    Then you can do flask run

提交回复
热议问题