【End of script output before headers: index.cgi】のエラーを解消したい
解決したいこと
【End of script output before headers: index.cgi】のエラーを解消したい
例)
FlaskでWEBアプリの製作を始めた初心者です。
レンタルサーバー上にミニコンダにて、Pythonの環境を整えました。
こちらを参考にしました
https://dattesar.com/xserver-pip-flask/
・・・・コードはここから・・・・・・・・・・
from flask import Flask
app = Flask(name)
#1
@app.route('/')
def hello_world():
return 'Hello, World!'
#2
@app.route("/main", methods=["GET", "POST"])
def main_page():
return render_templates("mainpage.html")
・・・ここまで・・・・・・・・・・・・・・・・・・
#1をブラウザにURLを直接入力すると、エラーにならず、ハローワールドと言ってくれます。
#2をブラウザにURLを直接入力すると、【Internal Server Error】となってしまいます
.htaccessはこうなっています
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /flask-test/index.cgi/$1 [QSA,L]
index.cgiはこうなっています
#! /home/wtsx0001/miniconda3/envs/flaskapp/bin/python
print("Content-Type: text/html\n\n")
from wsgiref.handlers import CGIHandler
from helloFlask import app
CGIHandler().run(app)
pyファイルはこうなっています
from flask import Flask
app = Flask(name)
@app.route('/')
def hello_world():
return 'Hello, World!'
@app.route("/main", methods=["GET", "POST"])
def main_page():
return render_templates("mainpage.html")
自分で試したこと
・エラーログの確認
[Sat Apr 15 15:32:53.182656 2023] [cgid:error] [pid 63184:tid 63694] [client 153.231.9.231:50954] End of script output before headers: index.cgi
との事でしたので、ヘッダーが終了する前にスクリプトが終わってしまった、という意味と思いましたので、それを中心に過去記事の検索⇒訂正⇒作り直し・・・・
3日程経ってしまいましたので、投稿させて頂きます。
初歩的な所で恐縮ですが、ご教授、お願い致します。