I badly need your help, I have been trying to solve this problem for a week now, unsuccessfully.
this is my flask/python app[![enter image description here][1]][1]
@app.route('/', methods=["GET", "POST"])
@app.route('/home', methods=["GET", "POST"])
def home():
return render_template("landing.html")
def contact():
if request.method == "POST":
data = request.form
data = request.form
send_email(data["name"], data["email"], data["subject"], data["message"])
return render_template("landing.html", msg_sent=True)
return render_template("landing.html", msg_sent=False)
def send_email(name, email, subject, message):
email_message = f"Subject: {subject}\n\nName: {name}\nEmail: {email}\nMessage:{message}"
with smtplib.SMTP("smtp.zoho.eu") as connection:
connection.starttls()
connection.login(OWN_EMAIL, OWN_PASSWORD)
connection.sendmail(OWN_EMAIL, OWN_EMAIL, email_message)
this is the landing.html part for the contact form:
<div class="col-lg-6">
<form name="sentMessage" id="contactForm" action="{{ url_for('home') }}" method="post" novalidate>
<div class="control-group">
<div class="form-group floating-label-form-group controls">
<label>Name</label>
<input type="text" name="name" class="form-control" placeholder="Name" id="name" required data-validation-required-message="Please enter your name.">
<p class="help-block text-danger"></p>
</div>
</div>
<div class="control-group">
<div class="form-group floating-label-form-group controls">
<label>Email Address</label>
<input type="email" name="email" class="form-control" placeholder="Email Address" id="email" required data-validation-required-message="Please enter your email address.">
<p class="help-block text-danger"></p>
</div>
</div>
<div class="control-group">
<div class="form-group col-xs-12 floating-label-form-group controls">
<label>Subject</label>
<input type="text" name="subject" class="form-control" placeholder="Subject" id="subject" required data-validation-required-message="Please enter the subject.">
<p class="help-block text-danger"></p>
</div>
</div>
<div class="control-group">
<div class="form-group floating-label-form-group controls">
<label>Message</label>
<textarea rows="5" name="message" class="form-control" placeholder="Message" id="message" required data-validation-required-message="Please enter a message."></textarea>
<p class="help-block text-danger"></p>
</div>
</div>
<br>
<div id="success"></div>
<button type="submit" class="btn btn-primary" id="sendMessageButton">Send</button>
</form>
I have 2 different errors depending if I am sending it from mobile or from Mac, the application logs shows status=200 if I am sending the from the mobile and status=404 if sent from Mac
2021-03-02T22:20:44.499516+00:00 heroku[router]: at=info method=POST path="/home" host=www.redwhisker.com request_id=ff810eb4-138f-4c80-a605-785b130c1ddf fwd="86.141.236.165" dyno=web.1 connect=0ms service=2ms status=200 bytes=10907 protocol=http
2021-03-02T22:22:08.721016+00:00 heroku[router]: at=info method=POST path="/home" host=www.redwhisker.com request_id=cbe2cfc0-d197-4eef-9e97-7d021ac34b32 fwd="86.141.236.165" dyno=web.1 connect=1ms service=3ms status=200 bytes=10907 protocol=http
2021-03-02T22:22:08.719985+00:00 app[web.1]: 10.8.36.208 - - [02/Mar/2021:22:22:08 +0000] "POST /home HTTP/1.1" 200 10744 "http://www.redwhisker.com/home" "Mozilla/5.0 (Linux; Android 10; SM-G965F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.181 Mobile Safari/537.36"
2021-03-02T22:28:47.733308+00:00 heroku[router]: at=info method=POST path="/home" host=www.redwhisker.com request_id=a2bead33-e8d5-4eed-879f-90ce41e52e7d fwd="86.141.236.165" dyno=web.1 connect=0ms service=2ms status=200 bytes=10907 protocol=http
2021-03-02T22:28:47.730454+00:00 app[web.1]: 10.39.168.78 - - [02/Mar/2021:22:28:47 +0000] "POST /home HTTP/1.1" 200 10744 "http://www.redwhisker.com/home" "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1"
2021-03-02T22:28:48.050319+00:00 heroku[router]: at=info method=GET path="/static/lib/bootstrap/css/bootstrap.min.css.map" host=www.redwhisker.com request_id=8330d006-3ae4-46ed-a803-d2e93f6b92d6 fwd="86.141.236.165" dyno=web.1 connect=2ms service=4ms status=404 bytes=400 protocol=http
2021-03-02T22:28:48.047736+00:00 app[web.1]: 10.39.168.78 - - [02/Mar/2021:22:28:48 +0000] "GET /static/lib/bootstrap/css/bootstrap.min.css.map HTTP/1.1" 404 232 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36"
2021-03-02T22:28:48.235576+00:00 app[web.1]: 10.39.168.78 - - [02/Mar/2021:22:28:48 +0000] "GET /static/lib/bootstrap/js/bootstrap.bundle.min.js.map HTTP/1.1" 404 232 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36"
2021-03-02T22:28:48.238169+00:00 heroku[router]: at=info method=GET path="/static/lib/bootstrap/js/bootstrap.bundle.min.js.map" host=www.redwhisker.com request_id=6b290b88-8cbf-4b64-8185-24eae023afdb fwd="86.141.236.165" dyno=web.1 connect=5ms service=4ms status=404 bytes=400 protocol=http
I am pretty new to flask/python and I am stuck on this can please someone help me out? Thanks!