รูปภาพไม่ขึ้นบนเว็บ Python+Werkzeug ทำอย่างไรได้บ้างครับ

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: รูปภาพไม่ขึ้นบนเว็บ Python+Werkzeug ทำอย่างไรได้บ้างครับ

Re: รูปภาพไม่ขึ้นบนเว็บ Python+Werkzeug ทำอย่างไรได้บ้างครับ

โดย mindphp » 10/02/2017 11:33 am

เปลี่ยน

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

 [('Content-Type', 'text/plain')])
เป็น

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

 [('Content-Type', 'text/html')])
output ที่ส่งออกมาก็จะเป็น html

ส่วน ข้อความที่จะแสดงก็แสดงเป็น tag html ออกมาจาก app ของเราได้เลย

Re: รูปภาพไม่ขึ้นบนเว็บ Python+Werkzeug ทำอย่างไรได้บ้างครับ

โดย Dive Demo » 10/02/2017 9:23 am

ผมต้องการเขียน Python ให้นำชื่อไฟล์จากโฟลดเดอร์ในเครื่อง ไปแสดงผลบน Browser อ่ะครับ Werkzeug ในที่นี้คือตัวเซริ์ฟเวอร์ที่นำคำสั่งจากจาก Python ไปแสดงผลบน Web Browser อ่ะครับ

Re: รูปภาพไม่ขึ้นบนเว็บ Python+Werzeug ทำอย่างไรได้บ้างครับ

โดย mindphp » 09/02/2017 7:03 pm

ไม่เข้าใจคำถาม ครับ ภาพขึ้นบน #werkzeug คืออะไร

รูปภาพไม่ขึ้นบนเว็บ Python+Werkzeug ทำอย่างไรได้บ้างครับ

โดย Dive Demo » 09/02/2017 6:42 pm

ต้องการให้รูปภาพของเราขึ้นบน Werkzeug ทำอย่างไรได้บ้างครับ

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

# -*- coding: utf-8 -*-
import time
from werkzeug.wrappers import Request, Response
from werkzeug.serving import run_simple
import os
fee = os.listdir("../img_magic/img_m")
for fill in fee:
      print fee
html = """ tag html  """

def wsgi_app(self, environ, start_response):
        request = Request(environ)
        response = self.dispatch_request(request)
        return response(environ, start_response)
    
def create_app(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return [fill + 'This time ---->  ' + time.ctime()]

run_simple('127.0.0.1', 5012, create_app, use_debugger=True, use_reloader=True)
error_werk2.png
error_werk2.png (10.17 KiB) Viewed 546 times

ข้างบน