modified: app.py
This commit is contained in:
47
app.py
47
app.py
@@ -1,16 +1,11 @@
|
|||||||
import os
|
import os
|
||||||
from flask import Flask, Response, render_template, jsonify, send_from_directory
|
from flask import Flask, render_template, jsonify
|
||||||
from flask.wrappers import Response
|
|
||||||
# Serve versions/version.json at /versions
|
|
||||||
@app.route('/versions')
|
|
||||||
def versions() -> Response:
|
|
||||||
return send_from_directory('versions', 'version.json', mimetype='application/json')
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
# Main routes
|
# Main routes
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def home() -> str:
|
def home():
|
||||||
"""Homepage with overview of Devanturas and featured projects"""
|
"""Homepage with overview of Devanturas and featured projects"""
|
||||||
projects = [
|
projects = [
|
||||||
{
|
{
|
||||||
@@ -77,7 +72,7 @@ def home() -> str:
|
|||||||
return render_template('index.html', projects=projects)
|
return render_template('index.html', projects=projects)
|
||||||
|
|
||||||
@app.route('/projects')
|
@app.route('/projects')
|
||||||
def projects() -> str:
|
def projects():
|
||||||
"""Overview of all projects"""
|
"""Overview of all projects"""
|
||||||
all_projects = [
|
all_projects = [
|
||||||
{
|
{
|
||||||
@@ -179,9 +174,9 @@ def projects() -> str:
|
|||||||
return render_template('projects.html', projects=all_projects)
|
return render_template('projects.html', projects=all_projects)
|
||||||
|
|
||||||
@app.route('/minecraft')
|
@app.route('/minecraft')
|
||||||
def minecraft() -> str:
|
def minecraft():
|
||||||
"""Dedicated Minecraft development page"""
|
"""Dedicated Minecraft development page"""
|
||||||
minecraft_projects: list[dict[str, str]] = [
|
minecraft_projects = [
|
||||||
{
|
{
|
||||||
'name': 'Fly Plugin',
|
'name': 'Fly Plugin',
|
||||||
'description': 'Flight plugin for survival servers',
|
'description': 'Flight plugin for survival servers',
|
||||||
@@ -218,9 +213,9 @@ def minecraft() -> str:
|
|||||||
return render_template('minecraft.html', projects=minecraft_projects, info=minecraft_info)
|
return render_template('minecraft.html', projects=minecraft_projects, info=minecraft_info)
|
||||||
|
|
||||||
@app.route('/about')
|
@app.route('/about')
|
||||||
def about() -> str:
|
def about():
|
||||||
"""About SimolZimol and Devanturas"""
|
"""About SimolZimol and Devanturas"""
|
||||||
skills: dict[str, list[str]] = {
|
skills = {
|
||||||
'Minecraft Development': [
|
'Minecraft Development': [
|
||||||
'Spigot & Paper Plugin Development',
|
'Spigot & Paper Plugin Development',
|
||||||
'Java Programming',
|
'Java Programming',
|
||||||
@@ -247,7 +242,7 @@ def about() -> str:
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
achievements: list[dict[str, str]] = [
|
achievements = [
|
||||||
{
|
{
|
||||||
'title': 'Fly Plugin',
|
'title': 'Fly Plugin',
|
||||||
'description': 'Active on Modrinth & SpigotMC',
|
'description': 'Active on Modrinth & SpigotMC',
|
||||||
@@ -268,9 +263,9 @@ def about() -> str:
|
|||||||
return render_template('about.html', skills=skills, achievements=achievements)
|
return render_template('about.html', skills=skills, achievements=achievements)
|
||||||
|
|
||||||
@app.route('/contact')
|
@app.route('/contact')
|
||||||
def contact() -> str:
|
def contact():
|
||||||
"""Contact information and links"""
|
"""Contact information and links"""
|
||||||
contact_links: list[dict[str, str]] = [
|
contact_links = [
|
||||||
{
|
{
|
||||||
'name': 'GitHub',
|
'name': 'GitHub',
|
||||||
'url': 'https://github.com/SimolZimol/',
|
'url': 'https://github.com/SimolZimol/',
|
||||||
@@ -304,12 +299,12 @@ def contact() -> str:
|
|||||||
|
|
||||||
# Healthcheck endpoint for platforms like Coolify
|
# Healthcheck endpoint for platforms like Coolify
|
||||||
@app.route('/health')
|
@app.route('/health')
|
||||||
def health() -> tuple[Response, Literal[200]]:
|
def health():
|
||||||
return jsonify(status='ok'), 200
|
return jsonify(status='ok'), 200
|
||||||
|
|
||||||
# Project detail pages
|
# Project detail pages
|
||||||
@app.route('/projects/fly-plugin')
|
@app.route('/projects/fly-plugin')
|
||||||
def fly_plugin() -> str:
|
def fly_plugin():
|
||||||
"""Detailed page for Fly Plugin"""
|
"""Detailed page for Fly Plugin"""
|
||||||
project = {
|
project = {
|
||||||
'name': 'Fly Plugin',
|
'name': 'Fly Plugin',
|
||||||
@@ -369,7 +364,7 @@ def fly_plugin() -> str:
|
|||||||
return render_template('project_detail.html', project=project)
|
return render_template('project_detail.html', project=project)
|
||||||
|
|
||||||
@app.route('/projects/hoi4-elo-bot')
|
@app.route('/projects/hoi4-elo-bot')
|
||||||
def hoi4_elo_bot() -> str:
|
def hoi4_elo_bot():
|
||||||
"""Detailed page for HOI4 ELO Bot"""
|
"""Detailed page for HOI4 ELO Bot"""
|
||||||
project = {
|
project = {
|
||||||
'name': 'Hearts of Iron IV ELO Bot',
|
'name': 'Hearts of Iron IV ELO Bot',
|
||||||
@@ -432,7 +427,7 @@ def hoi4_elo_bot() -> str:
|
|||||||
return render_template('project_detail.html', project=project)
|
return render_template('project_detail.html', project=project)
|
||||||
|
|
||||||
@app.route('/projects/discord-ai-bot')
|
@app.route('/projects/discord-ai-bot')
|
||||||
def discord_ai_bot() -> str:
|
def discord_ai_bot():
|
||||||
"""Detailed page for Discord AI Bot — Moderation & Giveaways"""
|
"""Detailed page for Discord AI Bot — Moderation & Giveaways"""
|
||||||
project = {
|
project = {
|
||||||
'name': 'Multus',
|
'name': 'Multus',
|
||||||
@@ -473,7 +468,7 @@ def discord_ai_bot() -> str:
|
|||||||
return render_template('project_detail.html', project=project)
|
return render_template('project_detail.html', project=project)
|
||||||
|
|
||||||
@app.route('/projects/discord-bot-stable-diffusion-amd')
|
@app.route('/projects/discord-bot-stable-diffusion-amd')
|
||||||
def discord_bot_stable_diffusion_amd() -> str:
|
def discord_bot_stable_diffusion_amd():
|
||||||
"""Detailed page for Discord Bot — Stable Diffusion (AMD)"""
|
"""Detailed page for Discord Bot — Stable Diffusion (AMD)"""
|
||||||
project = {
|
project = {
|
||||||
'name': 'Discord Bot — Stable Diffusion (AMD)',
|
'name': 'Discord Bot — Stable Diffusion (AMD)',
|
||||||
@@ -510,7 +505,7 @@ def discord_bot_stable_diffusion_amd() -> str:
|
|||||||
return render_template('project_detail.html', project=project)
|
return render_template('project_detail.html', project=project)
|
||||||
|
|
||||||
@app.route('/projects/levelcraft')
|
@app.route('/projects/levelcraft')
|
||||||
def levelcraft() -> str:
|
def levelcraft():
|
||||||
"""Detailed page for LevelCraft (Closed Source)"""
|
"""Detailed page for LevelCraft (Closed Source)"""
|
||||||
project = {
|
project = {
|
||||||
'name': 'LevelCraft',
|
'name': 'LevelCraft',
|
||||||
@@ -542,7 +537,7 @@ def levelcraft() -> str:
|
|||||||
return render_template('project_detail.html', project=project)
|
return render_template('project_detail.html', project=project)
|
||||||
|
|
||||||
@app.route('/projects/simpleteleport')
|
@app.route('/projects/simpleteleport')
|
||||||
def simpleteleport() -> str:
|
def simpleteleport():
|
||||||
"""Detailed page for SimpleTeleport"""
|
"""Detailed page for SimpleTeleport"""
|
||||||
project = {
|
project = {
|
||||||
'name': 'SimpleTeleport',
|
'name': 'SimpleTeleport',
|
||||||
@@ -612,5 +607,11 @@ def simpleteleport() -> str:
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Allow overriding via environment (e.g., Coolify sets PORT)
|
# Allow overriding via environment (e.g., Coolify sets PORT)
|
||||||
port = int(os.getenv('PORT', '5000'))
|
port = int(os.getenv('PORT', '5000'))
|
||||||
debug: bool = os.getenv('FLASK_DEBUG', 'false').lower() == 'true'
|
debug = os.getenv('FLASK_DEBUG', 'false').lower() == 'true'
|
||||||
app.run(debug=debug, host='0.0.0.0', port=port)
|
app.run(debug=debug, host='0.0.0.0', port=port)
|
||||||
|
|
||||||
|
# Serve /versions as JSON
|
||||||
|
@app.route('/versions')
|
||||||
|
def versions():
|
||||||
|
from flask import send_from_directory
|
||||||
|
return send_from_directory('versions', 'version.json', mimetype='application/json')
|
||||||
Reference in New Issue
Block a user