Skip to content

Instantly share code, notes, and snippets.

@lfarah
Created May 18, 2016 07:18
Show Gist options
  • Save lfarah/149a8079b81de5eadbf3ffab37edf70c to your computer and use it in GitHub Desktop.
Save lfarah/149a8079b81de5eadbf3ffab37edf70c to your computer and use it in GitHub Desktop.
MEH
import os
from flask import Flask,redirect
import re
app = Flask(__name__)
# f2 = open("README.md","r")
# # text = f2.readlines()
# SwiftCount = 0
# ObjCCount = 0
# # text = f2.readlines()
# # for line in text[138:]:
# # if "*" in line:
# # if ":large_orange_diamond:" in line:
# # print "Swift"
# # SwiftCount += 1
# # else:
# # print "Objc"
# # ObjCCount += 1
# # print "Swift: " + str(SwiftCount)
# # print "ObjC: " + str(ObjCCount)
# # # text2 = str(text)
# # # urls = re.findall('\(http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', text2)
# # # total = len(urls) - 11
# # # print "total: " + str(total)
@app.route('/swift')
def hello():
f2 = open("README.md","r")
text = f2.readlines()
swiftCount = 0
for line in text[138:]:
if "*" in line:
if ":large_orange_diamond:" in line:
swiftCount += 1
url = "https://img.shields.io/badge/swift_projects-" + str(swiftCount) + "-orange.svg"
return redirect(url, code=302)
@app.route('/objc')
def objc():
f2 = open("README.md","r")
text = f2.readlines()
ObjCCount = 0
for line in text[138:]:
if "*" in line:
if ":large_orange_diamond:" not in line:
ObjCCount += 1
url = "https://img.shields.io/badge/objc_projects-" + str(ObjCCount) + "-blue.svg"
return redirect(url, code=302)
if __name__ == '__main__':
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment