Skip to content

Commit

Permalink
push all
Browse files Browse the repository at this point in the history
  • Loading branch information
shahedex committed Mar 1, 2019
0 parents commit 5eccb49
Show file tree
Hide file tree
Showing 1,616 changed files with 283,701 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .Python
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn app:app
Binary file added __pycache__/cseindex.cpython-36.pyc
Binary file not shown.
Binary file added __pycache__/dseindex.cpython-36.pyc
Binary file not shown.
190 changes: 190 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
from flask import Flask, render_template
from flask import request
import psycopg2
import re
import base64
import os, time, http.client
import requests
import urllib.request
import threading
import time

app = Flask(__name__)

def run_check():
threading.Timer(60.0, run_check).start()
SITES = []
SITE_ID = {}
try:
conn = psycopg2.connect(host="localhost",database="websitechecker", user="postgres", password="")
"""
DATABASE_URL = os.environ['DATABASE_URL']
conn = psycopg2.connect(DATABASE_URL, sslmode='require')
"""
cur = conn.cursor()
query = "SELECT * from websites"
cur.execute(query)
results = cur.fetchall()
#"""
for res in results:
#print(res)
SITES.append(res[0])
SITE_ID[res[0]] = res[1]
#"""
conn.close()
except Exception as e:
print(e)
for site in SITES:
sheraa = site
if sheraa == "":
break
global response_status
response_time = 0
try:
# conn = http.client.HTTPSConnection(site+'/?', timeout=10)
# conn.request("HEAD", "/?")
# response = conn.getresponse()
response = requests.get(sheraa);
if response.status_code != 200:
response_status = 'DOWN'
else:
response_time = requests.get(sheraa).elapsed.total_seconds()
response_status = 'OK'
print (site+" " + str(response.status_code)+" " + str(response_status)+" " +str(response_time))

try:
conn = psycopg2.connect(host="localhost",database="websitechecker", user="postgres", password="")
"""
DATABASE_URL = os.environ['DATABASE_URL']
conn = psycopg2.connect(DATABASE_URL, sslmode='require')
"""
cur = conn.cursor()
query = "INSERT INTO websiteinfo (site_name, site_id, response_code, response_type, response_time) VALUES (%s, %s,%s,%s,%s)"
values = (sheraa, SITE_ID[sheraa], str(response.status_code), str(response_status), str(response_time))
cur.execute(query, values)
conn.commit()
count = cur.rowcount
print(count)
"""
filelist = []
for res in results:
filelist.append(res[1])
print(res)
count+=1
"""
conn.close()
except Exception as e:
print(e)
conn.close()

except Exception as e:
print (site+" "+str(e))

run_check()

@app.route('/')
def runpy():
global datacount
filelist = []
print("reloading....")
return render_template('index.html')

@app.route('/',methods=['post'])
def form_post():
global sitename
sitename = request.form['addr']
print(sitename)
if(sitename != ""):
try:
conn = psycopg2.connect(host="localhost",database="websitechecker", user="postgres", password="")
"""
DATABASE_URL = os.environ['DATABASE_URL']
conn = psycopg2.connect(DATABASE_URL, sslmode='require')
"""
cur = conn.cursor()
query = "INSERT INTO websites (site_name, monitoring_from) VALUES (%s, current_timestamp)"
values = (sitename,)
cur.execute(query, values)
conn.commit()
count = cur.rowcount
print(count)
"""
filelist = []
for res in results:
filelist.append(res[1])
print(res)
count+=1
"""
conn.close()
except Exception as e:
print(e)
try:
conn = psycopg2.connect(host="localhost",database="websitechecker", user="postgres", password="")
"""
DATABASE_URL = os.environ['DATABASE_URL']
conn = psycopg2.connect(DATABASE_URL, sslmode='require')
"""
cur = conn.cursor()
query = "SELECT * from websites"
cur.execute(query)
results = cur.fetchall()
#"""
for res in results:
print(res)
#"""
conn.close()
except Exception as e:
print(e)
return render_template('dashboard.html', results=results)

@app.route('/dashboard')
def dashboard():
print("dashboard....")
try:
conn = psycopg2.connect(host="localhost",database="websitechecker", user="postgres", password="")
"""
DATABASE_URL = os.environ['DATABASE_URL']
conn = psycopg2.connect(DATABASE_URL, sslmode='require')
"""
cur = conn.cursor()
query = "SELECT * from websites"
cur.execute(query)
results = cur.fetchall()
#"""
for res in results:
print(res)
#"""
conn.close()
except Exception as e:
print(e)
return render_template('dashboard.html', results=results)

@app.route('/dashboard/<int:website_id>')
def websiteinfo(website_id):
print(website_id)
global website_name
print("dashboard....")
try:
conn = psycopg2.connect(host="localhost",database="websitechecker", user="postgres", password="")
"""
DATABASE_URL = os.environ['DATABASE_URL']
conn = psycopg2.connect(DATABASE_URL, sslmode='require')
"""
cur = conn.cursor()
query = "SELECT * from websiteinfo WHERE site_id = %s"
values = (website_id,)
cur.execute(query, values)
results = cur.fetchall()
#"""
for res in results:
website_name = res[0]
#"""
conn.close()
except Exception as e:
print(e)
return render_template('dashboard-websiteinfo.html', results=results, website_name=website_name)

if __name__ == '__main__':
app.debug = True
app.run()
app.run(debug=True)
78 changes: 78 additions & 0 deletions bin/activate
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly

deactivate () {
unset -f pydoc >/dev/null 2>&1

# reset old environment variables
# ! [ -z ${VAR+_} ] returns true if VAR is declared at all
if ! [ -z "${_OLD_VIRTUAL_PATH+_}" ] ; then
PATH="$_OLD_VIRTUAL_PATH"
export PATH
unset _OLD_VIRTUAL_PATH
fi
if ! [ -z "${_OLD_VIRTUAL_PYTHONHOME+_}" ] ; then
PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
export PYTHONHOME
unset _OLD_VIRTUAL_PYTHONHOME
fi

# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then
hash -r 2>/dev/null
fi

if ! [ -z "${_OLD_VIRTUAL_PS1+_}" ] ; then
PS1="$_OLD_VIRTUAL_PS1"
export PS1
unset _OLD_VIRTUAL_PS1
fi

unset VIRTUAL_ENV
if [ ! "${1-}" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate
fi
}

# unset irrelevant variables
deactivate nondestructive

VIRTUAL_ENV="/Users/hello/dev/Varsity_Rating"
export VIRTUAL_ENV

_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH

# unset PYTHONHOME if set
if ! [ -z "${PYTHONHOME+_}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
unset PYTHONHOME
fi

if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
_OLD_VIRTUAL_PS1="$PS1"
if [ "x" != x ] ; then
PS1="$PS1"
else
PS1="(`basename \"$VIRTUAL_ENV\"`) $PS1"
fi
export PS1
fi

# Make sure to unalias pydoc if it's already there
alias pydoc 2>/dev/null >/dev/null && unalias pydoc

pydoc () {
python -m pydoc "$@"
}

# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH-}" ] || [ -n "${ZSH_VERSION-}" ] ; then
hash -r 2>/dev/null
fi
36 changes: 36 additions & 0 deletions bin/activate.csh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This file must be used with "source bin/activate.csh" *from csh*.
# You cannot run it directly.
# Created by Davide Di Blasi <davidedb@gmail.com>.

alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'

# Unset irrelevant variables.
deactivate nondestructive

setenv VIRTUAL_ENV "/Users/hello/dev/Varsity_Rating"

set _OLD_VIRTUAL_PATH="$PATH"
setenv PATH "$VIRTUAL_ENV/bin:$PATH"



if ("" != "") then
set env_name = ""
else
set env_name = `basename "$VIRTUAL_ENV"`
endif

# Could be in a non-interactive environment,
# in which case, $prompt is undefined and we wouldn't
# care about the prompt anyway.
if ( $?prompt ) then
set _OLD_VIRTUAL_PROMPT="$prompt"
set prompt = "[$env_name] $prompt"
endif

unset env_name

alias pydoc python -m pydoc

rehash

76 changes: 76 additions & 0 deletions bin/activate.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# This file must be used using `. bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
# Do not run it directly.

function deactivate -d 'Exit virtualenv mode and return to the normal environment.'
# reset old environment variables
if test -n "$_OLD_VIRTUAL_PATH"
set -gx PATH $_OLD_VIRTUAL_PATH
set -e _OLD_VIRTUAL_PATH
end

if test -n "$_OLD_VIRTUAL_PYTHONHOME"
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
set -e _OLD_VIRTUAL_PYTHONHOME
end

if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
# Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`.
set -l fish_function_path

# Erase virtualenv's `fish_prompt` and restore the original.
functions -e fish_prompt
functions -c _old_fish_prompt fish_prompt
functions -e _old_fish_prompt
set -e _OLD_FISH_PROMPT_OVERRIDE
end

set -e VIRTUAL_ENV

if test "$argv[1]" != 'nondestructive'
# Self-destruct!
functions -e pydoc
functions -e deactivate
end
end

# Unset irrelevant variables.
deactivate nondestructive

set -gx VIRTUAL_ENV "/Users/hello/dev/Varsity_Rating"

set -gx _OLD_VIRTUAL_PATH $PATH
set -gx PATH "$VIRTUAL_ENV/bin" $PATH

# Unset `$PYTHONHOME` if set.
if set -q PYTHONHOME
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
set -e PYTHONHOME
end

function pydoc
python -m pydoc $argv
end

if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
# Copy the current `fish_prompt` function as `_old_fish_prompt`.
functions -c fish_prompt _old_fish_prompt

function fish_prompt
# Save the current $status, for fish_prompts that display it.
set -l old_status $status

# Prompt override provided?
# If not, just prepend the environment name.
if test -n ""
printf '%s%s' "" (set_color normal)
else
printf '%s(%s) ' (set_color normal) (basename "$VIRTUAL_ENV")
end

# Restore the original $status
echo "exit $old_status" | source
_old_fish_prompt
end

set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
end
Loading

0 comments on commit 5eccb49

Please sign in to comment.