str.index
str.index(...)Description
Documentation for str.index.
Real-World Examples
Practical code examples showing how str.index is used in real projects.
# Create your views here.
from django.conf import settings
from django.http import HttpResponse
from github3 import login, GitHubStatus
def index(request):
return HttpResponse("<H1>Turn this page into a dashboard</H1>")
def status(request):
return HttpResponse("<H1>Put a global status page here</H1>")
def github_test(request):
response = "<H1>This page will test the github user credentials</H1>"
gh = login(settings.GITHUB_USERNAME, password=settings.GITHUB_TOKEN)
GitHubJanitor = gh.user()
response += "<p>User name: " + GitHubJanitor.name + "</p>"
response += "<p>Login: " + GitHubJanitor.login + "</p>"
response += "<p># Followers: " + str(GitHubJanitor.followers) + "</p>"
response += "<p># ratelimit_remaining: " + str(GitHubJanitor.ratelimit_remaining) + "</p>"
# count the forked repos for this user
search_results = gh.search_repositories('user:' + settings.GITHUB_USERNAME + ' fork:only',
sort=None,
Example 2
From vbondyrev/GitHub-RestAPI (app.py)
else:
return render_template("user.html", profile=user_info, repos=repos)
@app.route("/", methods=["GET", "POST"])
@app.route("/index", methods=["GET", "POST"])
@app.cache.cached(timeout=300) # cache this view for 5 minutes
def index():
""" By default - "GET" info about TOP 10 stars repo.
POST - get info about user
"""
if request.method == "POST":
github_username = request.form.get("github_username")
return redirect(url_for(".user_detail", user_name=github_username))
else:
response = requests.get(url_query_top10)
resp_dict = response.json()
resp_list = resp_dict["items"]
return render_template("index.html", repos=resp_list)
if __name__ == '__main__':
#app.run(host='127.0.0.1', port=5000, debug=True)
app.run(host='0.0.0.0', port=5000, debug=True)