🎨 Maintain multi-version structure

This commit is contained in:
zhbaor 2022-09-30 20:53:40 +08:00
parent dd88509251
commit ca8e01a475
154 changed files with 17396 additions and 7 deletions

47
data/render/31-2/server.py Executable file
View file

@ -0,0 +1,47 @@
#!/usr/bin/env python3
# # -*- coding: utf-8 -*-
import sys
import base64
import re
from bottle import route, run, static_file, view
sys.path.append("../../convert/31-2")
from db import *
db.bind(provider="sqlite", filename="../../clean/31-2/data.sqlite3")
db.generate_mapping()
@route("/<name>")
@view("weapon")
def melee(name):
with db_session:
query = select(w for w in Melee if w.name == name)
weapon = query.first()
mechanism, _ = re.subn(
r"{(.*?)@(.*?)}", r"<span class='\2'>\1</span>", weapon.mechanism
)
stats_map = {
1: "brutality",
2: "survival",
3: "minotaur",
4: "tactics",
5: "assassin",
6: "guardian",
}
return {
"title": name,
"icon": base64.b64encode(weapon.icon),
"mechanism": mechanism,
"description": weapon.description,
"stats": stats_map[weapon.stats]
}
@route("/static/<filepath:path>")
def server_static(filepath):
return static_file(filepath, root="./static")
run(host="localhost", port=8080)