สอบถาม เกี่ยวกับการ dump ค่าใน obj ออกมาดูต้องทำอยางไรครับ

แนะนำ สอบถาม ภาษา C สำหรับผู้เริ่มต้น ภาษา Java ภาษา Python

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
jirawoot
PHP VIP Members
PHP VIP Members
โพสต์: 3129
ลงทะเบียนเมื่อ: 17/06/2019 10:30 am

สอบถาม เกี่ยวกับการ dump ค่าใน obj ออกมาดูต้องทำอยางไรครับ

โพสต์ที่ยังไม่ได้อ่าน โดย jirawoot »

ผมดูค่าในตัวแปร response ออกมาดู มีวิธีไหนบ้างครับ ผมลอง ใช้ print แล้วมัน error ครับ
Selection_012.png
Selection_012.png (28.41 KiB) Viewed 563 times
โค้ด error

โค้ด: เลือกทั้งหมด

TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.

Traceback (most recent call last)
File "/home/com001/PycharmProjects/htmltoPdfImage2/venv/lib/python3.6/site-packages/flask/app.py", line 2328, in __call__
return self.wsgi_app(environ, start_response)
File "/home/com001/PycharmProjects/htmltoPdfImage2/venv/lib/python3.6/site-packages/flask/app.py", line 2314, in wsgi_app
response = self.handle_exception(e)
File "/home/com001/PycharmProjects/htmltoPdfImage2/venv/lib/python3.6/site-packages/flask/app.py", line 1760, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/com001/PycharmProjects/htmltoPdfImage2/venv/lib/python3.6/site-packages/flask/_compat.py", line 36, in reraise
raise value
File "/home/com001/PycharmProjects/htmltoPdfImage2/venv/lib/python3.6/site-packages/flask/app.py", line 2311, in wsgi_app
response = self.full_dispatch_request()
File "/home/com001/PycharmProjects/htmltoPdfImage2/venv/lib/python3.6/site-packages/flask/app.py", line 1835, in full_dispatch_request
return self.finalize_request(rv)
File "/home/com001/PycharmProjects/htmltoPdfImage2/venv/lib/python3.6/site-packages/flask/app.py", line 1850, in finalize_request
response = self.make_response(rv)
File "/home/com001/PycharmProjects/htmltoPdfImage2/venv/lib/python3.6/site-packages/flask/app.py", line 1976, in make_response
'The view function did not return a valid response. The'
TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.
To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

dump() shows all variables in the frame
dump(obj) dumps all that's known about the object
โค้ดโปรแกรม

โค้ด: เลือกทั้งหมด

@app.route('/test',methods=['GET'])
def convpdf():
    filename = request.args.get('filename')
    linkurl = request.args.get('linkurl')
    typefile = request.args.get('typefile')
    if typefile == '1':
        str = filename+'.pdf'
        global base_store_pathpdf
        path_bin = 'wkhtmltopdf'
        path = os.path.join(base_store_pathpdf, str)
        subprocess.call([path_bin, linkurl, path])
        path_sh='pdf/'+str
        # pdf = pdfkit.from_url(linkurl, False)
        response = send_file(path_sh)
        print( response)
ภาพประจำตัวสมาชิก
jirawoot
PHP VIP Members
PHP VIP Members
โพสต์: 3129
ลงทะเบียนเมื่อ: 17/06/2019 10:30 am

Re: สอบถาม เกี่ยวกับการ dump ค่าใน obj ออกมาดูต้องทำอยางไรครับ

โพสต์ที่ยังไม่ได้อ่าน โดย jirawoot »

สามารถใช้คำสั่ง for loop วนค่าเอามาดูโดยใช้โค้ดนี้

โค้ด: เลือกทั้งหมด

for attr in dir(response):
    print("obj.%s = %r" % (attr, getattr(response, attr)))
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 50