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

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

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

User avatar
jirawoot
PHP VIP Members
PHP VIP Members
Posts: 3130
Joined: 17/06/2019 10:30 am

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

Post by jirawoot »

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

Code: Select all

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
โค้ดโปรแกรม

Code: Select all

@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)
User avatar
jirawoot
PHP VIP Members
PHP VIP Members
Posts: 3130
Joined: 17/06/2019 10:30 am

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

Post by jirawoot »

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

Code: Select all

for attr in dir(response):
    print("obj.%s = %r" % (attr, getattr(response, attr)))
Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Return to “Programming - C/C++ & java & Python”

Who is online

Users browsing this forum: No registered users and 6 guests