Skip to content
Snippets Groups Projects
Unverified Commit 1f6b5ad8 authored by waraich1's avatar waraich1 Committed by GitHub
Browse files

Merge pull request #1 from waraich1/subreddit-route-initializer

Setup flask
parents 37305d8f 8e8f363c
No related branches found
No related tags found
No related merge requests found
## trenddit-backend
## Initialize Trenddit
python3 -m venv ./venv
source ./venv/bin/activate
pip install -r requirements.txt
## Run Backend
sh run.sh
from crypt import methods
import imp
import logging
import json
import os
from urllib import response
from flask import request, jsonify,Blueprint
subreddit_routes = Blueprint('subreddit',__name__)
@subreddit_routes.route("/subreddit_posts", methods = ['GET'])
def subreddit_get():
response = jsonify(
authError=True,
data={
'data': 'This works'
}
)
return response
\ No newline at end of file
import argparse
from ast import arguments
import logging
from click import argument
from flask_cors import CORS
from flask import Flask,request,session,abort,jsonify,Blueprint
import api.subreddit as subreddit_routes
app = Flask(__name__)
app.register_blueprint(subreddit_routes.subreddit_routes)
CORS(app)
@app.route("/")
def index():
return jsonify({"message": "Trenddit Backend!"})
def parse_args():
parser = argparse.ArgumentParser(description="Start the pg choral backend serverlet")
parser.add_argument("-ho","--host", type=str,help="The host for choral application",default="0.0.0.0")
parser.add_argument("-p","--port",type=int,help="The port for the application server",default=5000)
return parser.parse_args()
if __name__ == "__main__":
arguments = parse_args()
app.run(host=arguments.host,port=arguments.port,debug=True)
\ No newline at end of file
run.sh 0 → 100644
source ./venv/bin/activate
pip install -r requirements.txt
python3 application.py -p 5000
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment