1
我寫了一個web程序來寫入文件,然後讀取文件,並且失敗了。球拍網頁服務器寫入文件錯誤
而且程序代碼如下:
#lang web-server/insta
(define (start request)
(index-wrap request))
(define (index-wrap request)
(define (response-generator embed/url)
(response/xexpr
`(html
(head (title "test"))
(body
(h1 "Test Write")
(form ((action ,(embed/url write-handler)))
(input ((type "submit"))))))))
(define (write-handler request)
(call-with-output-file "write_file"
#:exists 'truncate
(lambda (out) (print "hello,world" out)))
(index-wrap request))
(send/suspend/dispatch response-generator))
當你按一下按鈕,它會出現一個錯誤:
call-with-output-file: cannot open output file
path: /usr/share/racket/pkgs/web-server-lib/web-server/default-web-root/htdocs/write_file
system error: Permission denied; errno=13
而且我也寫一個測試程序來測試呼叫用輸出文件功能,它寫文件成功。我的測試程序代碼如下:
#lang racket
(call-with-output-file "write_other"
#:exists 'truncate
(lambda (out) (print "hello,racket" out)))
那麼,什麼是關於它的問題?
路徑是(這裏是/ usr/share/racket/pkgs/web-server-lib/web-server/default-web-root/htdocs /) – huix
如何更改Web服務器寫入的路徑? – huix
@huix我已經添加了一些關於文件權限的信息。 – soegaard