-
Notifications
You must be signed in to change notification settings - Fork 3
/
forkinfo.py
32 lines (23 loc) · 918 Bytes
/
forkinfo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from flask import Flask, render_template,request,url_for,redirect
from GitHubRepo import Repository as repo
import random
app = Flask(__name__)
@app.route("/")
def index():
return render_template('index.html')
@app.route('/<path:reponame>')
def forkedrepos(reponame):
repo_owner = reponame.split('/')[0]
repoobj = repo(reponame)
forked_repos = repoobj.getForkedRepos()
if 'message' in repoobj.forkedrespjson:
return render_template('apierror.html', curr_msg = repoobj.forkedrespjson)
else:
return render_template('forks.html', cuur_repo_list= repoobj.forkedrespjson, parent_user = repo_owner)
@app.route('/forks', methods =['GET','POST'])
def forks():
if(request.method == "GET"):
return "Please submit the form direct get not allowed"
else:
repoin = request.form.get('repo')
return redirect(url_for('forkedrepos',reponame=repoin))