Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
115 views
in Technique[技术] by (71.8m points)

python - Apacher Server can't start with Blueprint

I started with raspberry pi program. My first project is a webserver. I use the apache with wsgi and flask.

If I start the init.py everthing is working on 127.0.0.1:5000. If I start die apache I get the problem from the log below and on the website [Apacher Server Internal Server Error].

init Code:

from flask import Flask, render_template, redirect, url_for, request, session, Blueprint
from p_auftrag import auftrag

app = Flask(__name__)
app.register_blueprint(auftrag)

@app.route("/")
def home():
    return render_template("index.html")

if __name__ == "__main__":
    app.run(debug=True)

p_auftrag Code:

from flask import Flask, render_template, redirect, url_for, request, session, Blueprint
from datetime import datetime

auftrag = Blueprint("p_auftrag",__name__,static_folder="static", template_folder="templates")
    
@auftrag.route("/auftrag/",methods=['GET',"POST"])
def auftragsite():
    if request.method == "POST":
        nummer= request.form["nm"]
        datei = open('log/log.txt','w')
        #print(datetime.date())
        datei.write("[ "+ str(datetime.now()) + " ]"+ " Auftragsnummer: "+str(nummer))
        return redirect(url_for("p_auftrag.nummer", nr=nummer))
    else:
        return render_template("auftrag.html")
    
@auftrag.route("/<nr>")
def nummer(nr):
    return render_template("auftrag_bestaetigung.html")

Log from apache:

[Sat Jan 09 17:46:32.694242 2021] [wsgi:error] [pid 578:tid 3046110240] [client 192.168.2.112:37814] mod_wsgi (pid=578): Failed to exec Python script file '/var/www/webApp/webapp.wsgi'.
[Sat Jan 09 17:46:32.694500 2021] [wsgi:error] [pid 578:tid 3046110240] [client 192.168.2.112:37814] mod_wsgi (pid=578): Exception occurred processing WSGI script '/var/www/webApp/webapp.wsgi'.
[Sat Jan 09 17:46:32.695537 2021] [wsgi:error] [pid 578:tid 3046110240] [client 192.168.2.112:37814] Traceback (most recent call last):
[Sat Jan 09 17:46:32.695653 2021] [wsgi:error] [pid 578:tid 3046110240] [client 192.168.2.112:37814]   File "/var/www/webApp/webapp.wsgi", line 7, in <module>
[Sat Jan 09 17:46:32.695723 2021] [wsgi:error] [pid 578:tid 3046110240] [client 192.168.2.112:37814]     from webApp import app as application
[Sat Jan 09 17:46:32.695751 2021] [wsgi:error] [pid 578:tid 3046110240] [client 192.168.2.112:37814]   File "/var/www/webApp/webApp/__init__.py", line 2, in <module>
[Sat Jan 09 17:46:32.695770 2021] [wsgi:error] [pid 578:tid 3046110240] [client 192.168.2.112:37814]     from p_auftrag import auftrag
[Sat Jan 09 17:46:32.695845 2021] [wsgi:error] [pid 578:tid 3046110240] [client 192.168.2.112:37814] ModuleNotFoundError: No module named 'p_auftrag'
[Sat Jan 09 17:46:33.519263 2021] [wsgi:error] [pid 579:tid 3046110240] [client 192.168.2.112:37816] mod_wsgi (pid=579): Failed to exec Python script file '/var/www/webApp/webapp.wsgi'., referer: http://192.168.2.112/
[Sat Jan 09 17:46:33.519399 2021] [wsgi:error] [pid 579:tid 3046110240] [client 192.168.2.112:37816] mod_wsgi (pid=579): Exception occurred processing WSGI script '/var/www/webApp/webapp.wsgi'., referer: http://192.168.2.112/
[Sat Jan 09 17:46:33.520060 2021] [wsgi:error] [pid 579:tid 3046110240] [client 192.168.2.112:37816] Traceback (most recent call last):, referer: http://192.168.2.112/
[Sat Jan 09 17:46:33.520140 2021] [wsgi:error] [pid 579:tid 3046110240] [client 192.168.2.112:37816]   File "/var/www/webApp/webapp.wsgi", line 7, in <module>, referer: http://192.168.2.112/
[Sat Jan 09 17:46:33.520159 2021] [wsgi:error] [pid 579:tid 3046110240] [client 192.168.2.112:37816]     from webApp import app as application, referer: http://192.168.2.112/
[Sat Jan 09 17:46:33.520184 2021] [wsgi:error] [pid 579:tid 3046110240] [client 192.168.2.112:37816]   File "/var/www/webApp/webApp/__init__.py", line 2, in <module>, referer: http://192.168.2.112/
[Sat Jan 09 17:46:33.520201 2021] [wsgi:error] [pid 579:tid 3046110240] [client 192.168.2.112:37816]     from p_auftrag import auftrag, referer: http://192.168.2.112/
[Sat Jan 09 17:46:33.520247 2021] [wsgi:error] [pid 579:tid 3046110240] [client 192.168.2.112:37816] ModuleNotFoundError: No module named 'p_auftrag', referer: http://192.168.2.112/
[Sat Jan 09 17:46:47.370148 2021] [mpm_event:notice] [pid 577:tid 3070181904] AH00491: caught SIGTERM, shutting down
question from:https://stackoverflow.com/questions/65645465/apacher-server-cant-start-with-blueprint

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...