Skip to content

Installation

jszh edited this page Apr 12, 2018 · 23 revisions

Prerequisites

Package name How to get it?
Node.js 8 (includes npm) https://nodejs.org/en/
Python 3 https://www.python.org/downloads/
PostgreSQL https://www.postgresql.org/download/

配置开发环境

First, set your app's secret key as an environment variable. For example, add the following to .bashrc or .bash_profile. For Windows, add to system preferences.

  1. 首先,在环境变量中设置一个密钥,名为 PAPERSMITH_SECRET,内容任意。Mac 和 Linux 使用以下代码,Windows 在系统设置中。Mac 和 Linux 下为了将这个环境变量持久化,不用每次输入,可以修改 ~/.bashrc,在其中也加入下面的命令。
export PAPERSMITH_SECRET='something-really-secret'
  1. Download the back end 下载后端(本项目)

    git clone https://github.com/ai-writing/Challenge2018
    git checkout dev   # 切换到 dev 分支
    cd Challenge2018   # 进入项目文件夹
    
  2. (Optional) It is recommended that you use virtualenv to manage the python environment. If you choose to do so, create a new virtual env and activate it 推荐使用 virtualenv(或 virtualenvwrapper)创建 python3 虚拟环境

    virtualenv venv
    . venv/bin/activate
    
  1. (Windows only) If you are using Windows, make sure to run this command first. Windows 用户请先执行以下命令

    npm install -g win-node-env
    

    (Windows 10 with python 3.6+ only) If you are using Python 3.6 or higher on Windows 10, make sure to run this command first. 在 Windows 10 和 python 3.6 环境下,请执行以下命令:

    chcp 65001
    
  2. Run the following commands to bootstrap your environment (make sure you are in the Challenge2018 directory) 配置本项目

    pip install -r requirements/dev.txt   # 安装依赖的 python 包
    npm install    # 安装依赖的 node 包
    npm run build  # 编译本项目
    
  3. 根据 Dependencies 的要求安装依赖。

  1. 启动系统

    npm start  # run the webpack dev server and flask server using concurrently
    

对于 Windows 用户,上述最后一条命令中可能报错,请 Ctrl-C 关闭这个命令。随后,可以通过以下的命令启动后端服务器。在配置完后,运行时也可以使用以下命令

set FLASK_APP=autoapp.py   # use "export" instead of "set" on Mac or Linux
flask run

环境变量也可以用第 1 步的方法持久化,这样以后就不用指定 FLASK_APP 了。Mac 和 Linux 用户也可以在一行内设置环境变量、运行:

FLASK_APP=autoapp.py flask run

至此,配置完毕。可以打开浏览器,访问 http://localhost:5000/,查看部署好的页面。

Clone this wiki locally