今回はDjangoで作った自分のサイトhttp://tokibito.orz.hm/をちょっとサーバー動作なしで動かしてみようかと思った。
E:\WebSitesにdjango-admin.pyで作ったプロジェクトフォルダが置かれてる状態。(ソースはSVNで管理してます)
とりあえずWindowsなのでコマンドだとUTF-8が文字化けしちゃうから、
E:\WebSites>chcp 65001
としておいた。このコマンドを実行する前に、コンソールのプロパティでフォントをMSゴシックにしとかないと日本語文字化けするんで注意。
python起動
E:\WebSites>python
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> import os, sys >>> os.environ['DJANGO_SETTINGS_MODULE'] = 'tkhp.settings' >>> import django.core.handlers.wsgi >>> application = django.core.handlers.wsgi.WSGIHandler() >>> application.load_middleware() >>> from django.http import HttpRequest >>> req = HttpRequest() >>> req.path = '/' >>> res = application.get_response(req) >>> print res Content-Type: text/html; charset=utf-8 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/ DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja"> <head> <title>tokibito's software</title> </head> <body> <div class="banner"> <img src="/static/image/tkhp_banner_200x40.jpg" width="200" height="40" alt= "tokibito's software" /> </div> <p> 準備中です。<br /> Ubuntu7.04 Apache2+mod_wsgiでDjango0.96(Python2.5)稼動中。<br /> 相変わらずDBはSQLite3使ってる。<br /> </p> </body>Traceback (most recent call last): File "<stdin>", line 1, in <module> IOError: [Errno 0] Error
IOErrorが出たのは何故だろう。もしかして表示できない文字でも含んでたのか。
ところでこの出力をDelphi+P4DでTWebBrowserに書き込めばブラウザで見れるよねって話。そういやIEコンポーネントでレスポンスをハックってどうやったらできるんだろか。画像とかのレンダリング方法を考えないと。
- 追記
res.contentをファイルに出力したらエラーは出なかった。