flask-mongodb-example:Flask Web应用程序的简单示例,该应用程序连接到MongoDB实例并执行简单的

  • G6_559399
    了解作者
  • 29.7KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-27 04:56
    上传日期
Flash-MongoDB示例Web应用 当前托管在项目 数据库凭证 登录MongoDB数据库的凭据必须存储在名为.env的文件中,出于安全原因,该文件未包含在此存储库中。 复制名为env.example的文件并将其另存为.env 编辑.env文件,并在指示的每个变量中输入您自己的数据库凭据 在本地运行 要在本地运行此应用,请执行以下操作: 设置Python虚拟环境 此命令创建一个名为.venv的新虚拟环境: python3 -m venv .venv 激活虚拟环境 激活名为.venv的虚拟环境... 在Windows上,运行: .venv \S cripts \a ctivate.bat 在Mac上,运行: source .venv/bin/activate 将依赖项安装到虚拟环境中 名为requirements.txt的文件包含一个依赖项列表-该应用程序依赖于其运行的其他
flask-mongodb-example-main.zip
  • flask-mongodb-example-main
  • .gitignore
    2KB
  • templates
  • read.html
    1.2KB
  • create.html
    1.1KB
  • index.html
    1.1KB
  • edit.html
    998B
  • requirements.txt
    157B
  • env.example
    244B
  • LICENSE
    34.3KB
  • myapp.py
    4.5KB
  • static
  • css
  • style.css
    213B
  • flask.cgi
    215B
  • README.md
    2.5KB
  • ux-design
  • flask-example-app-wireframes.drawio
    3.1KB
  • flask-example-app-wireframes.svg
    35KB
  • .vscode
  • settings.json
    122B
  • credentials.py
    769B
内容介绍
# Flash-MongoDB Example Web App Project currently hosted at https://i6.cims.nyu.edu/~ab1258/flask-mongodb-example/flask.cgi ## Database credentials The credentials for logging into a MongoDB database must be stored in a file named `.env`, which is not included in this repository for security reasons. 1. make a copy of the file named `env.example` and save it as `.env` 1. edit the `.env` file and enter your own database credentials into each of the variables where indicated ## Run locally To run this app locally, do the following: ### Set up a Python virtual environment This command creates a new virtual environment with the name `.venv`: ```bash python3 -m venv .venv ``` #### Activate the virtual environment To activate the virtual environment named `.venv`... On Windows, run: ```bash .venv\Scripts\activate.bat ``` On Mac, run: ```bash source .venv/bin/activate ``` #### Install the dependencies into the virtual environment The file named, `requirements.txt` contains a list of dependencies - other software modules that this app depends upon to run. To install the dependencies into the currently-active virtual environment, use `pip`, the default Python "package manager" - software that takes care of installing the correct version of any module into your in the correct place for the current environment. ```bash pip3 install -r requirements.txt ``` ### Run the app 1. define two environment variables from the command line: `export FLASK_APP=myapp` and `export FLASK_ENV=development` 1. start flask with `flask run` - this will output an address at which the app is running locally, e.g. https://127.0.0.1:5000. Visit that address in a web browser. ## Host on a web server The following steps outline how to host this application on NYU's **i6**.cims.nyu.edu web server. Other servers may vary. 1. Familiarize yourself with web hosting steps on a CIMS server from the link: https://cims.nyu.edu/webapps/content/systems/userservices/webhosting. 1. Use a file transfer program, such as Cyberduck, to copy your entire project directory to the `/home/$USER/public_html/` directory, where `$USER` is replaced by your own username. 1. Make the files named `flask.cgi` and `myapp.py` executable by all with the command, `chmod u+x flask.cgi` and `chmod u+x myapp.py`. 1. Your app should now be live at https://i6.cims.nyu.edu/~$USER/$flask-app-directory/flask.cgi, where `$USER` is replaced with your own **i6** username and `$flask-app-directory` is replaced with the name of the sub-directory within `public_html` where your flask app code resides.
评论
    相关推荐