This commit is contained in:
Gnawmon 2024-04-09 14:26:22 +03:00
commit d08c0ab8ca
8 changed files with 299 additions and 0 deletions

166
.gitignore vendored Normal file
View File

@ -0,0 +1,166 @@
3.0 KiB
Plaintext
# ---> Python
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
users.json

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# bring
a webring made with flask

58
app.py Normal file
View File

@ -0,0 +1,58 @@
import json
from flask import Flask, redirect, render_template
from markupsafe import escape
from waitress import serve
reader = open("users.json", "r")
data = json.loads(reader.read())
reader.close()
users = data["users"]
websites = data["websites"]
app = Flask(__name__, static_url_path='',
static_folder='web/static',
template_folder='web/templates')
@app.route("/<name>/next")
def getNextUser(name):
if(not name in users):
return "user not found."
nextUserId = users.index(name) + 1
if(nextUserId == len(users)):
nextUserId = 0
return redirect(websites[nextUserId])
@app.route("/<name>/previous")
def getPreviousUser(name):
if(not name in users):
return "user not found."
nextUserId = users.index(name) - 1
if(nextUserId == -1):
nextUserId = len(users) -1
print(nextUserId)
return redirect(websites[nextUserId])
@app.route("/<name>")
def getUserWebsite(name):
if(not name in users):
return "user not found."
return redirect(websites[users.index(name)])
@app.route("/users")
def listUsers():
thingToGive = ""
for user in users:
thingToGive = thingToGive + f"<a href=\"{websites[users.index(user)]}\" target=\"_blank\">{user}</a><br>"
return "<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"/css/users.css\"></head><body>"+ thingToGive+"<body><html>"
@app.route("/")
def home():
return render_template('index.html')
if __name__ == '__main__':
serve(app, host='127.0.0.1', port=9932)

43
web/static/css/style.css Normal file
View File

@ -0,0 +1,43 @@
:root {
--accent-color: rgb(255, 107, 255);
}
body {
background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 1, 12, 0.9)) , url("/images/bg2.jpg");
height: 100%;
background-size: cover;
background-repeat: no-repeat;
max-width: 40%;
margin: auto;
padding: 20px;
}
a,
h1,
h2,
h3,
h4,
h5,
p,
li {
font-family: 'Lato', sans-serif;
font-variant: normal;
color: rgb(218, 218, 218);
}
h1 {
text-align: center;
}
h1
,
h2 {
text-decoration: underline;
text-decoration-color: var(--accent-color);
}
a {
color: var(--accent-color);
}

9
web/static/css/users.css Normal file
View File

@ -0,0 +1,9 @@
:root {
--accent-color: rgb(255, 107, 255);
}
a {
font-family: 'Lato', sans-serif;
font-variant: normal;
color: var(--accent-color);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

BIN
web/static/images/bg2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

21
web/templates/index.html Normal file
View File

@ -0,0 +1,21 @@
<html>
<head>
<title>Bring</title>
<link rel="stylesheet" type="text/css" href="/css/style.css">
</head>
<body>
<h1>Bring</h1>
<p>Welcome to Bring's home page! <br></p>
<h2>Members</h2>
<iframe style="border: none; " src="/users"></iframe>
<h2>Rules</h2>
<ul>
<li>be human</li>
<li>navigation must be in the landing page</li>
<li>have a website</li>
</ul>
<h2>How to sign up</h2>
<p>Contact </p>
<a href="http://git.vern.cc/Gnawmon/bring" style="text-align:end;">Source Code</a>
</body>
</html>