linux - 如何从顶级目录之外运行烧瓶应用程序?
问题描述
我正在研究 Miguel Grinberg 的 Flask Megatutorial(一个微博应用程序),使用 Amazon EC2 ubuntu 微实例。
目前,每次我想启动烧瓶应用程序时,我都必须cd
进入顶级目录~/microblog/
。
然后,我输入: flask run -h 0.0.0.0 -p 50000
启动应用程序。
有没有办法在命令行中指定目录,这样我就不必继续去目录运行程序了?似乎没有,但也许我错过了一些东西。我对linux也很陌生。
~/microblog$ flask run --help
* Tip: There are .env or .flaskenv files present. Do "pip install python-dotenv" to use them.
Usage: flask run [OPTIONS]
Run a local development server.
This server is for development purposes only. It does not provide the
stability, security, or performance of production WSGI servers.
The reloader and debugger are enabled by default if FLASK_ENV=development
or FLASK_DEBUG=1.
Options:
-h, --host TEXT The interface to bind to.
-p, --port INTEGER The port to bind to.
--cert PATH Specify a certificate file to use HTTPS.
--key FILE The key file to use when specifying a
certificate.
--reload / --no-reload Enable or disable the reloader. By default
the reloader is active if debug is enabled.
--debugger / --no-debugger Enable or disable the debugger. By default
the debugger is active if debug is enabled.
--eager-loading / --lazy-loader
Enable or disable eager loading. By default
eager loading is enabled if the reloader is
disabled.
--with-threads / --without-threads
Enable or disable multithreading.
--extra-files PATH Extra files that trigger a reload on change.
Multiple paths are separated by ':'.
--help Show this message and exit.
解决方案
你可以做
export FLASK_APP=<your_directory>
然后运行命令,如果您想导出变量并持久使用 nano、vi 或您喜欢的编辑器将其添加到 ~/.bash_profile 文件的末尾
推荐阅读
- machine-learning - 异常值的准确预测
- prestashop - 如何在 Prestashop 1.6 中手动延迟加载图像?
- php - 将其转换为准备好的语句
- c++ - 有没有办法让 Visual Studio 假定 #define 的值?
- ruby-on-rails - 使用 Ruby 和 MongoID 排序不排序
- kotlin - 检查字符串上的小写和大写
- animation - 如何从 2018 FBX SDK 中获取反向绑定姿势矩阵?
- ngxs - 如何从 NGXS 商店获取以前的状态
- php - 字符串到数组,由新行和括号分割
- javascript - 800ms 后删除下一个 div 的类