Coder Social home page Coder Social logo

questionnaire-for-reddit's Introduction

Questionnaire For Reddit

Deploy

Requirements

In order to test this you will need:

  • Python 3.10. This could probably be made to work with Python 2.7 as well or any Python 3.x, but I prefer Python 3.
  • Some PostgreSQL installation. You can use a portable installation as well:
  • The libraries in Pipfile
    • Flask: The base for the web site
    • praw: For interaction with reddit
    • ruamel.yaml: For YAML reading (much nicer than PyYAML)
    • gunicorn: This is used from heroku as their web server
    • SQLAlchemy: For database interaction
    • pg8000: Since I'm using a postgres, we need to have a way to connect.
    • psycopg2: I only use pg8000, but SQLAlchemy asks for this, too
    • flask_sqlalchemy: A way to connect Flask with SQLAlchemy.

Setup

Reddit application

Before you start testing, you need to create a reddit application.

  1. Head over to reddit app preferences and click on the "are you a developer? create an app..." (or "create another app...") button.
    1. Put as name whatever you want (e.g. questionnaire for /r/mysubreddit (in development)). I put in development in there to separate it from when it goes live.
    2. Leave (*) Web app selected.
    3. Enter whatever you want in the description (or even nothing at all).
    4. You can also leave the about field empty. Or put a http://localhost:5000/about
    5. The only important part: In the redirect uri put http://localhost:5000/authorize_callback
    6. Press the "create app" button
  2. Take note of the Client ID and the Client Secret
    1. ClientID is immediately below the "web app" thingie
    2. Secret is the first field below that.

That's it. I probably made it sound harder than it is.

Here's the process in screenshots:

Go to reddit app preferences (step 1 above):
Go to prefs/apps page

Fill in the values (step 1.1 through 1.5 above):
Create an application

After pressing the "create app button" (step 1.6 above):
Application done

Note the client id (yellow) and the client secret (orange) (step 2 above):
Client ID and Client Secret

Database

Ok, now you just need to create a new database to record any answers. This will only be for development, of course. If/when you deploy to heroku, the database will be created from heroku itself.

If you have chosen to download the raw binaries (Windows or Linux), you should also run the following batch file (just put it on the folder you've unzipped the binaries)

@ECHO OFF
REM The script sets environment variables helpful for PostgreSQL
SET PATH="%~dp0\bin";%PATH%
SET PGDATA=%~dp0\data
SET PGDATABASE=postgres
SET PGUSER=postgres
SET PGPORT=5432
SET PGLOCALEDIR=%~dp0\share\locale
REM The line below is only needed the first time you run this
IF NOT EXIST "%PGDATA%" (
    "%~dp0\bin\initdb" -U postgres -A trust
)
"%~dp0\bin\pg_ctl" -D "%~dp0/data" -l logfile start
ECHO Press any key to stop server
PAUSE
"%~dp0\bin\pg_ctl" -D "%~dp0/data" stop

or, for Linux

#!/bin/sh
# The script sets environment variables helpful for PostgreSQL
export PATH=$PATH:$(pwd)/bin
export PGDATA=$(pwd)/data
export PGDATABASE=postgres
export PGUSER=postgres
export PGPORT=5432
export PGLOCALEDIR=$(pwd)/share/locale
echo $PATH
echo $PGDATA
# The line below is only needed the first time you run this
if [ ! -d "$PGDATA" ]; then
    $(pwd)/bin/initdb -U postgres -A trust
fi
$(pwd)/bin/pg_ctl -D $(pwd)/data -l logfile start
read -p "Press [Enter] to stop server." key
$(pwd)/bin/pg_ctl -D $(pwd)/data stop

Environment variables:

When developing, you need to set up the following environment variables (either at system level, or set them up in a batch file).

questionnaire-for-reddit's People

Contributors

dependabot[bot] avatar gschizas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

bonzei123

questionnaire-for-reddit's Issues

Question syntax

Hi!
Is there any sample file for the questionfile?
yaml or json

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.