-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
46 lines (26 loc) · 1007 Bytes
/
Copy pathmain.py
File metadata and controls
46 lines (26 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from flask import Flask, render_template, request, redirect
from EmailSending import EmailSending
from Weather import Weather
app = Flask(__name__, template_folder='WeatherApp/templates')
def TODO(message="Functionality not implemented"):
raise NotImplementedError(message)
@app.route('/', methods=['GET', 'POST'])
def submit():
if request.method == 'POST':
# Get form data
city = request.form.get('city')
email = request.form.get('email')
# Get weather data
weatherObj = Weather(city)
message = weatherObj.weather()
# Send email
emailObj = EmailSending(message)
emailObj.sending(email)
return render_template('success.html', city=city, email=email)
return render_template('index.html')
@app.route('/success')
def success():
return render_template('success.html')
if __name__ == '__main__':
app.add_url_rule('/<path:path>', endpoint='catch_all', view_func=submit)
app.run(port=5002)