Hi,
Firstly thank you very much ... I have to python files and they are in the same folder, named app folder... one is main.py and the other is sendemail1.py and there is wsgi.py file under the virtual directory. But when i run the wsgi.py it gives me the ModuleNotFoundError: No module named 'sendemail1' error so i can not push to heroku...
my wsgi.py is;
from app.main import app
if name == "main":
app.run()
main.py file is:
from flask import Flask, render_template, request
from flask_sqlalchemy import SQLAlchemy
from sendemail1 import sendemail
from sqlalchemy.sql import func
...
app= Flask(name)
app.config['SQLALCHEMY_DATABASE_URI']='postgresql://postgres:123456@localhost/height_collector'
class Data(db.Model): tablename="data"
id=db.Column(db.Integer,primary_key=True)
email_=db.Column(db.String(120),unique=True)
height_=db.Column(db.Integer)
subject="Height Data"
message ="Hey , your height is <strong> %s. <strong> Average height of all is %s and calculated out <strong> %s <strong> of people. " % (height, avg_height,count)
msg = MIMEText(message,'html')
msg['Subject']=subject
msg['To']=to_email
msg['From']=from_email
gmail=smtplib.SMTP('smtp.gmail.com',587)
gmail.ehlo()
gmail.starttls()
gmail.login(from_email,from_password)
gmail.send_message(msg)
Hi again,
i found the error...It is because i have to write the import like this
from app.sendemail1 import sendemail to the main.py
than it works
have a great day
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi,
Firstly thank you very much ... I have to python files and they are in the same folder, named app folder... one is main.py and the other is sendemail1.py and there is wsgi.py file under the virtual directory. But when i run the wsgi.py it gives me the ModuleNotFoundError: No module named 'sendemail1' error so i can not push to heroku...
my wsgi.py is;
from app.main import app
if name == "main":
app.run()
main.py file is:
from flask import Flask, render_template, request
from flask_sqlalchemy import SQLAlchemy
from sendemail1 import sendemail
from sqlalchemy.sql import func
...
app= Flask(name)
app.config['SQLALCHEMY_DATABASE_URI']='postgresql://postgres:123456@localhost/height_collector'
class Data(db.Model):
tablename="data"
id=db.Column(db.Integer,primary_key=True)
email_=db.Column(db.String(120),unique=True)
height_=db.Column(db.Integer)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/success",methods=['POST'])
def success():
if request.method=='POST':
email=request.form["email_name"]
height=request.form["height_name"]
if name=='main':
app.debug=True
app.run()
sendemail1.py file is
from email.mime.text import MIMEText
import smtplib
def sendemail(email,height,avg_height,count):
from_email="usertestblabla@gmail.com"
from_password="eee134566"
to_email=email
thank you very much
Hi again,
i found the error...It is because i have to write the import like this
from app.sendemail1 import sendemail to the main.py
than it works
have a great day