Skip to content
Open

idk #73

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
72cfff1
commit
jxtdav3 Sep 12, 2025
ece2e63
Delete index.html
jxtdav3 Sep 12, 2025
a849bbb
Update app.py
jxtdav3 Sep 12, 2025
adf1557
Create require.txt
jxtdav3 Sep 12, 2025
aa627ee
just hi
jxtdav3 Sep 12, 2025
db31637
yo
jxtdav3 Sep 12, 2025
174195b
add html
jxtdav3 Sep 12, 2025
a3fd91a
templates
jxtdav3 Sep 12, 2025
b06a2c1
add log
jxtdav3 Sep 12, 2025
2e1e38e
logn
jxtdav3 Sep 12, 2025
6d361bc
url for login
jxtdav3 Sep 12, 2025
679400a
red
jxtdav3 Sep 12, 2025
535ba2c
log out
jxtdav3 Sep 12, 2025
f4e6b5e
style sgn out
jxtdav3 Sep 12, 2025
423263e
continue
jxtdav3 Sep 12, 2025
8e678a3
iso
jxtdav3 Sep 12, 2025
cd363ad
coms
jxtdav3 Sep 12, 2025
9be3f4a
sub
jxtdav3 Sep 12, 2025
c686a67
call
jxtdav3 Sep 13, 2025
107abb4
lll
jxtdav3 Sep 13, 2025
6c0a063
pss
jxtdav3 Sep 13, 2025
7014474
Update app.py
jxtdav3 Sep 13, 2025
51e405f
clien
jxtdav3 Sep 13, 2025
889db39
fin
jxtdav3 Sep 13, 2025
4dc70f0
fin2
jxtdav3 Sep 13, 2025
9bc04d4
rrr
jxtdav3 Sep 13, 2025
0b7c815
rid
jxtdav3 Sep 13, 2025
817c9a5
req
jxtdav3 Sep 13, 2025
9136494
cv
jxtdav3 Sep 13, 2025
df3fe4f
require
jxtdav3 Sep 13, 2025
4a5cadb
call
jxtdav3 Sep 13, 2025
f316ae4
req
jxtdav3 Sep 13, 2025
74dc1f1
Delete requirements.txt
jxtdav3 Sep 15, 2025
9219468
requiire brought
jxtdav3 Sep 15, 2025
5fac2b4
upd requ
jxtdav3 Sep 15, 2025
3fc4ab7
torch out
jxtdav3 Sep 15, 2025
2a34159
due goog
jxtdav3 Sep 15, 2025
a636698
new req
jxtdav3 Sep 15, 2025
7da2c7c
new homepage
jxtdav3 Sep 15, 2025
2dfb2b2
test
jxtdav3 Sep 15, 2025
12058e7
change
jxtdav3 Sep 15, 2025
574a0b9
conc
jxtdav3 Sep 15, 2025
a8001eb
comm
jxtdav3 Sep 15, 2025
22db5f4
bday
jxtdav3 Sep 15, 2025
543363b
go
jxtdav3 Sep 15, 2025
bb66200
CHA
jxtdav3 Sep 15, 2025
480c872
back
jxtdav3 Sep 15, 2025
1ce0150
size
jxtdav3 Sep 15, 2025
1e80321
css
jxtdav3 Sep 15, 2025
cfcb464
backk
jxtdav3 Sep 15, 2025
51c850b
size phone
jxtdav3 Sep 15, 2025
77e0aa4
static
jxtdav3 Sep 16, 2025
e8d8764
link
jxtdav3 Sep 16, 2025
155b889
stat
jxtdav3 Sep 16, 2025
495cb8e
dk
jxtdav3 Sep 16, 2025
d740b8d
changes
jxtdav3 Sep 17, 2025
cde8e3a
Update home.css
jxtdav3 Sep 19, 2025
2244718
Add files via upload
jxtdav3 Sep 19, 2025
98a8ffa
Add files via upload
jxtdav3 Sep 19, 2025
e0fe057
requuu
jxtdav3 Sep 23, 2025
32bfb62
Update app.py
jxtdav3 Sep 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"python-envs.defaultEnvManager": "ms-python.python:system",
"python-envs.pythonProjects": []
}
110 changes: 105 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,106 @@
from flask import Flask
app = Flask(__name__)
# IMPOPRTS
from flask import Flask, render_template, session, abort, redirect, url_for, request
import pathlib,os
from google.oauth2 import id_token
from google_auth_oauthlib.flow import Flow
from pip._vendor import cachecontrol
import google.auth.transport.requests
import requests

@app.route('/')
def hello_world():
return 'Hello, World!'
app = Flask("Studsight") # Initialize Flask app
app.secret_key = "davidneastudsightkey.com" # Secret key for session management

client_secrets_file = os.path.join(pathlib.Path(__file__).parent, "client_secret.json") # Path to client secrets file
GOOGLE_CLIENT_ID = "771970138692-gjilmd2o08eitr81o07oiuhfe7m5ardh.apps.googleusercontent.com" # Your Google Client ID for OAuth 2.0

# Example initialization (update with your actual client secrets file and scopes)
#links to the google oauth 2.0 server for authentication
flow = Flow.from_client_secrets_file(
client_secrets_file=client_secrets_file,
scopes=[
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email",
"openid"
],
redirect_uri="https://nea-studsight.onrender.com/callback" # Your redirect URI once authentication is complete

)


# Decorator to check if user is logged in before accessing certain routes
def login_is_required(function):
def wrapper(*args, **kwargs):

if "google_id" not in session:
abort(401) # Authorisation required
else:
return function() # Call the original function

return wrapper

@app.route("/login") # Login route
def login():
authorization_url, state = flow.authorization_url() # Get authorization URL and state reply from Google
session["state"] = state
return redirect(authorization_url)


# @app.route("/callback") # Callback route
# def callback():
# flow.fetch_token(authorization_response=request.url)

# if not session["state"] == request.args["state"]:
# abort(500) # State does not match!

# credentials = flow.credentials
# request_session = request.session()
# cached_session = cachecontrol.CacheControl(request_session)
# token_request = google.auth.transport.requests.Request(session=cached_session)

# id_info = id_token.verify_oauth2_token(
# id_token=credentials._id_token,
# request=token_request,
# audience=GOOGLE_CLIENT_ID
# )
# return id_info



@app.route("/callback") # Callback route to handle Google's response
def callback():
flow.fetch_token(authorization_response=request.url)
if not session["state"] == request.args["state"]:
abort(500)
credentials = flow.credentials
request_session = requests.session()
cached_session = cachecontrol.CacheControl(request_session)
token_request = google.auth.transport.requests.Request(session=cached_session)
id_info = id_token.verify_oauth2_token(
id_token=credentials._id_token,
request=token_request,
audience=GOOGLE_CLIENT_ID
)
session["google_id"] = id_info.get("sub")
session["email"] = id_info.get("email")
return redirect("/protected_area")


@app.route("/logout") # Logout route to clear session
def logout():
session.clear()
return redirect("/")


@app.route("/") # Home route, which is the landing page when the app is accessed
def home():
return render_template("home.html")

# Protected area route, accessible only after login.
@app.route("/protected_area") #This is where the people who have access to the app will go after logging in to view the app's main content.
@login_is_required
def protected_area():
return render_template("protected_area.html", email=session["google_id"])


if __name__ == "__main__": # Run the app
app.run(debug=True)
13 changes: 13 additions & 0 deletions client_secret.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"web": {
"client_id": "771970138692-gjilmd2o08eitr81o07oiuhfe7m5ardh.apps.googleusercontent.com",
"project_id": "nea-studsight",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "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",
"redirect_uris": [
"https://nea-studsight.onrender.com/callback"
]
}
}
127 changes: 127 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,129 @@
Flask
SQLAlchemy
PyInputPlus
Gunicorn
google-api-python-client
google-auth
google-auth-oauthlib
google-auth-httplib2
anyio==4.9.0
argon2-cffi==25.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==3.0.0
async-lru==2.0.5
attrs==25.3.0
babel==2.17.0
beautifulsoup4==4.13.4
bleach==6.2.0
certifi==2025.7.9
cffi==1.17.1
charset-normalizer==3.4.2
colorama==0.4.6
comm==0.2.2
contourpy==1.3.2
cycler==0.12.1
debugpy==1.8.14
decorator==5.2.1
defusedxml==0.7.1
executing==2.2.0
fastjsonschema==2.21.1
filelock==3.13.1
fonttools==4.58.5
fqdn==1.5.1
fsspec==2024.6.1
gitdb==4.0.12
GitPython==3.1.44
h11==0.16.0
httpcore==1.0.9
httpx==0.28.1
idna==3.10
ipykernel==6.29.5
ipython==9.4.0
ipython_pygments_lexers==1.1.1
isoduration==20.11.0
jedi==0.19.2
Jinja2==3.1.6
joblib==1.5.1
json5==0.12.0
jsonpointer==3.0.0
jsonschema==4.24.0
jsonschema-specifications==2025.4.1
jupyter-events==0.12.0
jupyter-lsp==2.2.5
jupyter-server-mathjax==0.2.6
jupyter_client==8.6.3
jupyter_core==5.8.1
jupyter_server==2.16.0
jupyter_server_terminals==0.5.3
jupyterlab==4.4.4
jupyterlab_git==0.51.2
jupyterlab_pygments==0.3.0
jupyterlab_server==2.27.3
kiwisolver==1.4.8
MarkupSafe==3.0.2
matplotlib==3.10.3
matplotlib-inline==0.1.7
mistune==3.1.3
mpmath==1.3.0
narwhals==1.46.0
nbclient==0.10.2
nbconvert==7.16.6
nbdime==4.0.2
nbformat==5.10.4
nest-asyncio==1.6.0
networkx==3.3
notebook_shim==0.2.4
numpy==2.3.1
overrides==7.7.0
packaging==25.0
pandas==2.3.1
pandocfilters==1.5.1
parso==0.8.4
pexpect==4.9.0
pillow==11.3.0
platformdirs==4.3.8
plotly==6.2.0
prometheus_client==0.22.1
prompt_toolkit==3.0.51
psutil==7.0.0
ptyprocess==0.7.0
pure_eval==0.2.3
pycparser==2.22
Pygments==2.19.2
pyparsing==3.2.3
python-dateutil==2.9.0.post0
python-json-logger==3.3.0
pytz==2025.2
PyYAML==6.0.2
pyzmq==27.0.0
referencing==0.36.2
requests==2.32.4
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpds-py==0.26.0
scikit-learn==1.7.0
scipy==1.16.0
seaborn==0.13.2
Send2Trash==1.8.3
setuptools==80.9.0
six==1.17.0
smmap==5.0.2
sniffio==1.3.1
soupsieve==2.7
stack-data==0.6.3
sympy==1.13.3
terminado==0.18.1
threadpoolctl==3.6.0
tinycss2==1.4.0
tornado==6.5.1
traitlets==5.14.3
types-python-dateutil==2.9.0.20250708
typing_extensions==4.14.1
tzdata==2025.2
uri-template==1.3.0
urllib3==2.5.0
wcwidth==0.2.13
webcolors==24.11.1
webencodings==0.5.1
websocket-client==1.8.0
Loading