rc-niceties

所属分类:网络编程
开发工具:Python
文件大小:0KB
下载次数:0
上传日期:2023-03-07 01:31:26
上 传 者sh-1993
说明:  递归中心的批处理结束细节,
(End of batch niceties for the Recurse Center,)

文件列表:
.eslintrc (331, 2022-03-19)
LICENSE (1073, 2022-03-19)
Procfile (65, 2022-03-19)
SFPixelate-Bold.ttf (47656, 2022-03-19)
backend/ (0, 2022-03-19)
backend/__init__.py (1929, 2022-03-19)
backend/api.py (12474, 2022-03-19)
backend/auth.py (3781, 2022-03-19)
backend/cache.py (1810, 2022-03-19)
backend/config.py (3003, 2022-03-19)
backend/mock/ (0, 2022-03-19)
backend/mock/__init__.py (0, 2022-03-19)
backend/mock/fixtures/ (0, 2022-03-19)
backend/mock/fixtures/batches.json (487, 2022-03-19)
backend/mock/fixtures/batches_people.json (4226, 2022-03-19)
backend/mock/fixtures/comments.json (699, 2022-03-19)
backend/mock/fixtures/people_me.json (1129, 2022-03-19)
backend/mock/rc.py (1107, 2022-03-19)
backend/models.py (2862, 2022-03-19)
backend/static.py (6184, 2022-03-19)
backend/templates/ (0, 2022-03-19)
backend/templates/nicetiesbyusers.html (863, 2022-03-19)
backend/templates/printniceties.html (1745, 2022-03-19)
backend/util.py (2028, 2022-03-19)
migrations/ (0, 2022-03-19)
migrations/alembic.ini (857, 2022-03-19)
migrations/env.py (2707, 2022-03-19)
migrations/script.py.mako (494, 2022-03-19)
migrations/versions/ (0, 2022-03-19)
migrations/versions/490ca3791aac_.py (2742, 2022-03-19)
migrations/versions/67ac3b7d5c2f_remove_column_faculty_reviewed_from_.py (493, 2022-03-19)
migrations/versions/e88e0781857f_.py (1108, 2022-03-19)
mock.py (56, 2022-03-19)
package-lock.json (1233807, 2022-03-19)
package.json (812, 2022-03-19)
public/ (0, 2022-03-19)
public/favicon.ico (4286, 2022-03-19)
... ...

# rc-niceties An application to manage niceties delivered by [recursers](https://recurse.com) at the end of their batch. ## Application architecture This application is pretty simple. It stores niceties as text and some metadata associated with a unique (author, recipient, batch) tuple. This is stored in a Postgres database. Faculty can view and edit all the niceties. Recursers can see all the nice things said about them, and all the things they have said in the past. The backend is in [Flask](https://flask.palletsprojects.com/en/1.1.x/), and is just a REST API. The DB is Postgres, with [SQLAlchemy](https://docs.sqlalchemy.org/en/13/) as an ORM and [Alembic](https://alembic.sqlalchemy.org/en/latest/#) to manage schema migrations. The frontend is in [react](https://reactjs.org/), because it's 2016 and that's the current hotness. ## Creating a development environment I built this using Python 3.6.13, node.js 14.15.5 and Postgres 12.6. 1. Clone the repository into an appropriate location. 2. Set up your Python virtual environment by running `pyvenv venv` in that directory and running `source venv/bin/activate` to active it. 3. Install Python requirements with `pip install -r requirements.txt`. You may need to install some [build prerequisites](https://www.psycopg.org/docs/install.html#build-prerequisites); on Debian-like systems, they include the packages `python3-dev` and `libpq-dev`. 4. Install the frontend requirements with `npm install`. 5. [Install PostgreSQL](https://www.postgresql.org/download/) and create an empty database, e.g. `createdb rcniceties` 6. Set the following environment variables, noting that the application **will not run** if any of these is not set: * `FLASK_APP` - the location of the app, e.g. `backend:app` * `FLASK_SECRET_KEY_B64` - a base64-encoded random secret string, for example generated by running: ```python from base64 import b64encode from os import urandom print(b64encode(urandom(24))) ``` * `DATABASE_URL` - the database connection URL `e.g. postgres://localhost/rcniceties` * `RC_OAUTH_ID` - your Recurse Center OAuth application ID * `RC_OAUTH_SECRET` - your Recurse Center OAuth application secret * `DEV` - set to either `TRUE` or `FALSE`, depending on if this is a development or production environment * `DEBUG_SHOW_ALL` (optional) - set to `TRUE` to show every nicety in the DB on the Niceties For Me page (useful for debugging) or `FALSE` (default) for normal behavior A common way of setting up these environment variables is with a `.env` file in your project directory, containing `export ENV_VAR=value` on each line. This can be loaded by running `source .env` and will be automatically loaded by `heroku local`. 7. Optionally mock out the RC API by setting `MOCK_OUT_RC_API = True` in `backend/__init__.py`. This means you do not have to set `RC_OAUTH_ID` or `RC_OAUTH_SECRET`, but you'll only get sample data (contained in the `mock/fixtures` folder, and with request -> filename mapping in `mock/rc.py`). Alternatively, you'll need to [set up an RC application](https://recurse.com/settings/oauth) with a redirect URI pointing to your local server (e.g. `http://localhost:8000/login/authorized`) or with the special value `urn:ietf:wg:oauth:2.0:oob`. 8. At the command prompt, run `flask db upgrade` to create the DB tables. 9. Run `python`, and inside it run: ```python from backend import config config.set_to_default() ``` To run: 1. Compile the frontend static files by running `npm run build`. 2. Run the Flask application with `gunicorn backend:app --log-file -`. ## Deploying This is designed to be deployed to Heroku. To do this: 1. Enable the Python and node.js buildpacks for the application. 2. Set up a Postgres database for the application and run `heroku pg:push [database-name] DATABASE_URL` to copy your local database to Heroku.

近期下载者

相关文件


收藏者