Access sets using /set_num

This commit is contained in:
FrederikBaerentsen 2024-02-29 13:44:28 -05:00
parent 2e2eab7d6f
commit edaaf910ca
3 changed files with 9 additions and 10 deletions

12
app.py
View File

@ -3,10 +3,10 @@ import json
from pprint import pprint as pp
app = Flask(__name__)
tmp = '71386-10'
#tmp = '71386-10'
@app.route('/')
def index():
@app.route('/<tmp>')
def index(tmp):
with open('./sets/'+tmp+'/info.json') as info:
info_file = json.loads(info.read())
with open('./sets/'+tmp+'/inventory.json') as inventory:
@ -14,12 +14,12 @@ def index():
with open('./info/'+tmp+'.json') as info:
json_file = json.loads(info.read())
pp(json_file['unit'][0]['bricks']['missing'])
return render_template('bootstrap_table.html', title=info_file['set_num']+" - "+info_file['name'],
return render_template('bootstrap_table.html', tmp=tmp,title=info_file['set_num']+" - "+info_file['name'],
info_file=info_file,inventory_file=inventory_file,json_file=json_file)
@app.route('/saveNumber', methods=['POST'])
def save_number():
@app.route('/<tmp>/saveNumber', methods=['POST'])
def save_number(tmp):
data1 = request.form.get('brick.part.part_num')
data2 = request.form.get('brick.color.name')
data3 = request.form.get('index')

View File

@ -54,9 +54,8 @@ if Path("./info/"+set_num + ".json").is_file():
with open("./info/" + set_num + ".json",'w') as f:
json.dump(data,f,indent = 4)
else:
with open(set_path+'info.json', 'w', encoding='utf-8') as f:
json.dump(response, f, ensure_ascii=False, indent=4)
with open(set_path+'info.json', 'w', encoding='utf-8') as f:
json.dump(response, f, ensure_ascii=False, indent=4)
# save set image to folder
set_img_url = response["set_img_url"]

View File

@ -32,7 +32,7 @@
<td>
{% set ns = namespace(count='') %}
<form action="/saveNumber" method="post">
<form action="/{{ tmp }}/saveNumber" method="post">
<input type="hidden" name="brick.part.part_num" value="{{ brick.part.part_num }}">
<input type="hidden" name="count" value="{{ i }}">
<input type="hidden" name="index" value="{{ loop.index0 }}">