Uses Django now because Flask is insecure in prod

This commit is contained in:
2025-10-22 10:57:48 +01:00
parent ddf4caba62
commit 6c5453ad17
25 changed files with 112 additions and 204 deletions

4
.gitignore vendored
View File

@@ -2,4 +2,6 @@
mastodon-status/*
venv/
__pycache__/
settings.py
__init__.py
db.sqlite3

Binary file not shown.

View File

@@ -1,102 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="/index.css">
</head>
<body>
<pre>
<a href="/" class="no-spin">
__ __ __
---------/\ \__ /\ \ /\ \__
---------\ \ ,_\ __ __ __ _ ___ ___ _ __ \_\ \ ___ __\ \ ,_\
----------\ \ \/ /\ \/\ \/\ \/'\ /'___\ / __`\/\`'__\/'_` \ /'_ `\ /'__`\ \ \/
-----------\ \ \_\ \ \_\ \/> &lt;//\ \__//\ \L\ \ \ \//\ \L\ \ __/\ \/\ \/\ __/\ \ \_
------------\ \__\\ \____//\_/\_\ \____\ \____/\ \_\\ \___,_\/\_\ \_\ \_\ \____\\ \__\
-------------\/__/ \/___/ \//\/_/\/____/\/___/ \/_/ \/__,_ /\/_/\/_/\/_/\/____/ \/__/</a>
A friendly Linux community.
</pre>
<b><u>Services we provide:</u></b>
<ul>
<li>
<a href="https://mastodon.tuxcord.net">Mastodon</a> (<a href='/mastodon-status'>Status</a>)
</li>
<li>
<a href="https://git.javalsai.tuxcord.net">Gitea</a>
</li>
<li>
<a href="https://redlib.tuxcord.net">Redlib</a>
</li>
<li>
<a href="/mc">Minecraft</a>
</li>
<li>
Matrix server: matrix.tuxcord.net (please ask deadvey for access)
</li>
</ul>
<b><u>Join us:</u></b>
<ul>
Our Matrix and Discord are bridged, irc is not and is not very active.
<li>
<a href="https://matrix.to/#/#TuxCord:matrix.org">Matrix</a>
</li>
<li>
<a href="https://discord.gg/SPHymEDytw">Discord</a>
</li>
<li>
<a href="irc://irc.tuxcord.net">irc.tuxcord.net</a>
</li>
</ul>
<details>
<summary>
<u><b>Members:</b></u>
</summary>
<ul>
<li><u>pickzelle (Founder)</u></li>
<li>bruhhhhh😘</li>
<li><a href="https://git.javalsai.tuxcord.net/danmax">Danmax</a></li>
<li><a href="https://deadvey.tuxcord.net">DeaDvey</a></li>
<li><a href="https://github.com/ErrorNoInternet">ErrorNoInternet</a></li>
<li>grialion</li>
<li><a href="https://javalsai.tuxcord.net">Javalsai</a></li>
<li><a href="https://decompil.in/">Spamix</a></li>
</ul>
</details>
<div class="tuxcord-image">
<pre>
.-"""-.
' \
|,. ,-. |
|()L () \ |
|,' `".| |
|.___.',| `
.j `--"' ` `.
/ ' ' \
/ / ` `.
/ / ` .
/ / l |
. , TuxCord | |
_ ,"`. .| |
| ' ``. | [..-'l
/ `.`, | '--' `.
( `. __.j )
\_ |--""___| ,-'
`"--...,+"""" `._,.-' <a href="http://roysac.com/tutorial/diamondieasciiarttutorial.html">mh</a>
</pre>
</div>
</body>
<footer>
<hr/>
<div id="footer-links">
<a href="https://git.javalsai.tuxcord.net/deadvey/tuxcord.net">Source Code</a>
/
<a href="https://javalsai.tuxcord.net">Gitea, Hosted by Javalsai</a>
/
<a href="https://envs.net">Website inspired by envs.net</a>
</div>
</footer>
</html>

36
main.py
View File

@@ -1,34 +1,32 @@
from flask import Flask, render_template, request, redirect
from django.shortcuts import render
from django.urls import path
from django.http import HttpResponse
import os
from datetime import datetime
app = Flask(__name__)
def decide_ascii():
day = datetime.today().strftime('%d')
month = datetime.today().strftime('%m')
if month == "12":
return open(f'./ascii/christmas.html', 'r').read()
return open('./ascii/christmas.html', 'r').read()
if month == "10":
return open(f'./ascii/halloween.html', 'r').read()
return open('./ascii/halloween.html', 'r').read()
else:
return open(f'./ascii/normal.html', 'r').read()
return open('./ascii/normal.html', 'r').read()
@app.route('/')
def index():
def index(request):
ascii_penguin = decide_ascii()
return render_template('index.html', ascii_penguin = ascii_penguin)
return render(request, 'index.html', {'ascii_penguin': ascii_penguin})
@app.route('/mc')
def mc():
def mc(request):
ascii_penguin = decide_ascii()
return render_template('mc.html', ascii_penguin = ascii_penguin)
return render(request, 'mc.html', {'ascii_penguin': ascii_penguin})
urlpatterns = [
path('', index, name='index'),
path('mc', mc, name='mc'),
]
if __name__ == '__main__':
app.run(
debug = True,
host = "0.0.0.0",
port = 8081
)
# In your main file (e.g., manage.py or wsgi.py), set up the server to run.
# Django handles the server running automatically. Configure your settings as needed.

Binary file not shown.

View File

@@ -1,78 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="/index.css">
</head>
<body>
<pre>
<a href="/" class="no-spin">
__ __ __
---------/\ \__ /\ \ /\ \__
---------\ \ ,_\ __ __ __ _ ___ ___ _ __ \_\ \ ___ __\ \ ,_\
----------\ \ \/ /\ \/\ \/\ \/'\ /'___\ / __`\/\`'__\/'_` \ /'_ `\ /'__`\ \ \/
-----------\ \ \_\ \ \_\ \/> &lt;//\ \__//\ \L\ \ \ \//\ \L\ \ __/\ \/\ \/\ __/\ \ \_
------------\ \__\\ \____//\_/\_\ \____\ \____/\ \_\\ \___,_\/\_\ \_\ \_\ \____\\ \__\
-------------\/__/ \/___/ \//\/_/\/____/\/___/ \/_/ \/__,_ /\/_/\/_/\/_/\/____/ \/__/</a>
A friendly Linux community.
</pre>
Name: Tuxcord-MC<br/>
IP/Server Address: mc.tuxcord.net<br/>
Version: 1.12.8<br/>
The server has a whitelist, so join our <a href="https://discord.gg/SPHymEDytw">Discord</a>, <a href="https://matrix.to/#/!BEyFZOZpWRoRrhRJbp:matrix.org">Matrix</a> or <a href="irc://irc.tuxcord.net">irc.tuxcord.net</a> and ask<br/>if you can join in the #.minecraft channel.<br/>
The server is cracked, so as to prevent bots and spam, we also have a registration system.<br/>
</pre>
<br/>
Rules:<br/>
<ol>
<li>
Joking around is Ok, but no directed hate speech.
</li>
<li>
Greifing and killing others is permitted.
</li>
<li>
No attempting to crash server or disrupt other people's gameplay with lag machines and the like.
</li>
<li>
While greifing is permitted in most cases, do not greif the main end island
</li>
</ol>
<div class="tuxcord-image">
<pre>
.-"""-.
' \
|,. ,-. |
|()L () \ |
|,' `".| |
|.___.',| `
.j `--"' ` `.
/ ' ' \
/ / ` `.
/ / ` .
/ / l |
. , TuxCord | |
_ ,"`. .| |
| ' ``. | [..-'l
/ `.`, | '--' `.
( `. __.j )
\_ |--""___| ,-'
`"--...,+"""" `._,.-' <a href="http://roysac.com/tutorial/diamondieasciiarttutorial.html">mh</a>
</pre>
</div>
</body>
<footer>
<hr/>
<div id="footer-links">
<a href="https://git.javalsai.tuxcord.net/deadvey/tuxcord.net">Source Code</a>
/
<a href="https://javalsai.tuxcord.net">Gitea, Hosted by Javalsai</a>
/
<a href="https://envs.net">Website inspired by envs.net</a>
</div>
</footer>
</html>

Binary file not shown.

View File

@@ -1,3 +0,0 @@
<meta charset="UTF-8" />
<link rel="stylesheet" href="/static/index.css">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 KiB

22
tuxcord/manage.py Executable file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tuxcord.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -0,0 +1,5 @@
{% load static %}
<meta charset="UTF-8" />
<link rel="stylesheet" href="{% static 'index.css' %}">
<title>Tuxcord.NET</title>

View File

@@ -8,6 +8,6 @@
-----------\ \ \_\ \ \_\ \/> &lt;//\ \__//\ \L\ \ \ \//\ \L\ \ __/\ \/\ \/\ __/\ \ \_
------------\ \__\\ \____//\_/\_\ \____\ \____/\ \_\\ \___,_\/\_\ \_\ \_\ \____\\ \__\
-------------\/__/ \/___/ \//\/_/\/____/\/___/ \/_/ \/__,_ /\/_/\/_/\/_/\/____/ \/__/</a>
A friendly Linux community.
A friendly Linux community.
</pre>

16
tuxcord/tuxcord/asgi.py Normal file
View File

@@ -0,0 +1,16 @@
"""
ASGI config for tuxcord project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.2/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tuxcord.settings')
application = get_asgi_application()

32
tuxcord/tuxcord/urls.py Normal file
View File

@@ -0,0 +1,32 @@
from django.shortcuts import render
from django.urls import path
from django.http import HttpResponse
import os
from datetime import datetime
def decide_ascii():
day = datetime.today().strftime('%d')
month = datetime.today().strftime('%m')
if month == "12":
return open('./ascii/christmas.html', 'r').read()
if month == "10":
return open('./ascii/halloween.html', 'r').read()
else:
return open('./ascii/normal.html', 'r').read()
def index(request):
ascii_penguin = decide_ascii()
return render(request, 'index.html', {'ascii_penguin': ascii_penguin})
def mc(request):
ascii_penguin = decide_ascii()
return render(request, 'mc.html', {'ascii_penguin': ascii_penguin})
urlpatterns = [
path('', index, name='index'),
path('mc', mc, name='mc'),
]
# In your main file (e.g., manage.py or wsgi.py), set up the server to run.
# Django handles the server running automatically. Configure your settings as needed.

16
tuxcord/tuxcord/wsgi.py Normal file
View File

@@ -0,0 +1,16 @@
"""
WSGI config for tuxcord project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/5.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tuxcord.settings')
application = get_wsgi_application()