From ff55977559ec22f21343d60594f89a08df7ddcd1 Mon Sep 17 00:00:00 2001 From: Justin Campbell Date: Tue, 21 Jul 2020 10:20:32 -0400 Subject: [PATCH] Update docs, add Python requirements file --- .gitignore | 9 ++- Dev Environment Setup Guide.md | 40 +++++++++- api/requirements.txt | 18 +++++ ...ng Apache2 and mod_wsgi on Ubuntu 18.04.md | 74 ------------------- 4 files changed, 61 insertions(+), 80 deletions(-) create mode 100644 api/requirements.txt delete mode 100644 docs/Installing Apache2 and mod_wsgi on Ubuntu 18.04.md diff --git a/.gitignore b/.gitignore index 396f1e8..acc39b8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ /node_modules /.pnp .pnp.js -/api/venv # Testing /coverage @@ -12,7 +11,7 @@ # Productiom /build -# misc +# Misc .DS_Store .env.local .env.development.local @@ -20,7 +19,11 @@ .env.production.local .vscode/ -# Node package management +# Node Package Management npm-debug.log* yarn-debug.log* yarn-error.log* + +# Python Files +/api/venv +__pycache__/ \ No newline at end of file diff --git a/Dev Environment Setup Guide.md b/Dev Environment Setup Guide.md index 1bbb698..a319ead 100644 --- a/Dev Environment Setup Guide.md +++ b/Dev Environment Setup Guide.md @@ -1,15 +1,17 @@ # Dev Environment Setup Guice ## Prerequisites +- [VS Code](https://code.visualstudio.com/download) - [NodeJS](https://nodejs.org/en/) >= v14.2.0 - npm >= v6.14.4 - npx >= v6.14.4 +- Python 3 ## Setup **Note:** webqueue2 uses npm and create-react-app to manage itself. You can learn more about npm [here](https://nodesource.com/blog/an-absolute-beginners-guide-to-using-npm/) and create-react-app [here](https://create-react-app.dev/docs/getting-started/). -### Step 1: Create a Project Directory +### Step 1: Create and enter a project directory ```bash mkdir project-dir && cd project-dir ``` @@ -24,7 +26,7 @@ git clone https://github.rcac.purdue.edu/ECN/webqueue2.git npm install ``` -### Step 4: Start Developing +#### Using npm There are three built in npm scripts that come from create-react-app: 1. `npm run start`: This will start a local development server on [localhost:3000](http://localhost:3000) and launch your default browser at that address. As you save changes in /public and/or /src you'll see your changes in the browser. @@ -33,4 +35,36 @@ There are three built in npm scripts that come from create-react-app: 1. `npm run test`: This will run any tests (using the [Jest](https://jestjs.io/) tester). There are currently no defined tests. -1. `npm run eject`: **THIS IS NON-REVERSABLE**: This will abstract all of the build environment settings and make them available to you. See the [create-reacte-app docs on ejecting](https://create-react-app.dev/docs/available-scripts#npm-run-eject) for more information. \ No newline at end of file +1. `npm run eject`: **THIS IS NON-REVERSABLE**: This will abstract all of the build environment settings and make them available to you. See the [create-reacte-app docs on ejecting](https://create-react-app.dev/docs/available-scripts#npm-run-eject) for more information. + +### Step 4: Setup Python for API +Go to the API directory +```bash +cd api/ +``` + +Activate the Python virtual environment +```bash +source venv/bin/activate +``` + +Install Python requiements +```bash +pip install -r requirements.txt +``` + +### Step 5: Configure VS Code + +#### Installing Plugins +- [ES Lint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) for JavaScript linting +- [Babel JavaScript](https://marketplace.visualstudio.com/items?itemName=mgmcdermott.vscode-language-babel) for JavaScript and JSX syntac highlighting and error checking +- [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) for working with Python virtual environments and debugging + +Optionally: +- [Remote - SSH](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh) for directly editing files on remote machine +- [Markdown Preview GitHub Styling](https://marketplace.visualstudio.com/items?itemName=bierner.markdown-preview-github-styles) for previewing Markdown as it will appear on GitHub + +#### Configuring Environemnt +- Python will need some workspace and debugger configuration to work. See [Getting Started with Python in VS Code](https://code.visualstudio.com/docs/python/python-tutorial) for more info. +- Remote - SSH will requires hosts to be added to your SSH config file. See [this guide](https://linuxize.com/post/using-the-ssh-config-file/) for more info. +- ES Lint, Babel JavaScript and Markdown Preview GitHub Styling will work without further configuration \ No newline at end of file diff --git a/api/requirements.txt b/api/requirements.txt new file mode 100644 index 0000000..e4e0060 --- /dev/null +++ b/api/requirements.txt @@ -0,0 +1,18 @@ +aniso8601==8.0.0 +astroid==2.4.2 +click==7.1.2 +Flask==1.1.2 +Flask-RESTful==0.3.8 +isort==4.3.21 +itsdangerous==1.1.0 +Jinja2==2.11.2 +lazy-object-proxy==1.4.3 +MarkupSafe==1.1.1 +mccabe==0.6.1 +pylint==2.5.3 +pytz==2020.1 +six==1.15.0 +toml==0.10.1 +typed-ast==1.4.1 +Werkzeug==1.0.1 +wrapt==1.12.1 diff --git a/docs/Installing Apache2 and mod_wsgi on Ubuntu 18.04.md b/docs/Installing Apache2 and mod_wsgi on Ubuntu 18.04.md deleted file mode 100644 index 9a10f33..0000000 --- a/docs/Installing Apache2 and mod_wsgi on Ubuntu 18.04.md +++ /dev/null @@ -1,74 +0,0 @@ -# Installing Apache2 and mod_wsgi on Ubuntu 18.04 - -Prepare the system: -```bash -# Update the System -sudo apt update && sudo apt upgrade -y - -# Install Apache, mod_wsgi, and python3-venv module -sudo apt install apache2 libapache2-mod-wsgi-py3 python3-venv -y - -# Add User to www-data Group -sudo usermod -aG $(whoami) www-data -``` - -For the group assignment to take effect you need to logout and back in. - -Prepare document root: -```bash -# Make Directory Structure in Root of: -. -└── api - └── webqueue2_api - ├── __init__.py - └── webqueue2_api.wsgi - -# Create Python virtual environment -cd /var/www/html && python3 -m venv venv -``` - -**__init__.py:** (Whatever the API code is) -```python -from flask import Flask -app = Flask(__name__) -@app.route("/") -def hello(): - return "Hello, Flask!" -if __name__ == "__main__": - app.run() -``` - -**webqueue2_api.wsgi** (Code calling the Flask app) -```python -#!/usr/bin/python3 -import sys -sys.path.insert(0,"/var/www/html/api") -from webqueue2_api import app as application -``` -Configure Apache2 -```bash -# Add Apache configuration -sudo nano /etc/apache2/sites-available/flasksite.conf -``` - -**flasksite.conf** -``` -WSGIPythonHome /var/www/html/api/webqueue2_api/venv - - ServerAdmin webmaster@localhost - DocumentRoot /var/www/html - - ErrorLog ${APACHE_LOG_DIR}/error.log - CustomLog ${APACHE_LOG_DIR}/access.log combined - - WSGIScriptAlias /api /var/www/html/api/webqueue2_api/webqueue2_api.wsgi - -``` - -```bash -# Enable the new site -sudo a2ensite flasksite.conf - -# Reload apache2 -sudo systemctl reload apache2 -``` \ No newline at end of file