💄 Rendered 31-4 images
This commit is contained in:
parent
c7bbe9521d
commit
3dd2967dce
252 changed files with 303 additions and 0 deletions
69
data/render/31-4/server.py
Executable file
69
data/render/31-4/server.py
Executable file
|
@ -0,0 +1,69 @@
|
|||
#!/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-4")
|
||||
from db import *
|
||||
|
||||
db.bind(provider="sqlite", filename="../../clean/31-4/data.sqlite3")
|
||||
db.generate_mapping()
|
||||
|
||||
|
||||
@route("/weapon/<name>")
|
||||
@view("weapon")
|
||||
def weapon(name):
|
||||
with db_session:
|
||||
query = select(w for w in Melee if w.name == name)
|
||||
if query.count() == 0:
|
||||
query = select(w for w in Shield if w.name == name)
|
||||
weapon = query.first()
|
||||
if query.count() == 0:
|
||||
query = select(w for w in Ranged if w.name == name)
|
||||
weapon = query.first()
|
||||
if weapon.mechanism:
|
||||
mechanism, _ = re.subn(
|
||||
r"{(.*?)@(.*?)}", r"<span class='\2'>\1</span>", weapon.mechanism
|
||||
)
|
||||
else:
|
||||
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("/outfit/<name>")
|
||||
@view("outfit")
|
||||
def weapon(name):
|
||||
with db_session:
|
||||
query = Outfit.select(name=name)
|
||||
outfit = query.first()
|
||||
return {
|
||||
"title": name,
|
||||
"icon": base64.b64encode(outfit.icon),
|
||||
"description": outfit.description,
|
||||
"preview": base64.b64encode(outfit.preview),
|
||||
}
|
||||
|
||||
|
||||
@route("/static/<filepath:path>")
|
||||
def server_static(filepath):
|
||||
return static_file(filepath, root="./static")
|
||||
|
||||
|
||||
run(host="localhost", port=8080)
|
Loading…
Add table
Add a link
Reference in a new issue