คำถามคือ ถ้าผมต้องการ ที่จะดึง ค่า ตัวแปร x นั้นมาแสดงในหน้าแก้ไขด้วย (เพราะไม่ได้บันทึกลงฐานข้อมูล) จะต้องใช้วิธีใด
ต้องดึงค่าจากไฟล์ rml หรือไม่ หรือว่าต้องทำยังไง
โค้ดรับค่าและ เก็บไว้ในตัวแปร เพื่อทำการแปลงไฟล์
Code: Select all
code = request.form['rml']
try:
f = open('code.rml', 'w')
f.write(code)
f.close()
print ('สร้างไฟล์สำเร็จ')
try:
d = open('code.rml', 'r')
data = d.read()
d.close()
pdf = rml2pdf.parseString(data.decode('utf-8'))
a = open('test.pdf', 'w')
a.write(pdf.read())
print ('แปลงไฟล์สำเร็จ')
except:
print ('แปลงไฟล์ผิดพลาด')