-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
29 lines (23 loc) · 770 Bytes
/
app.py
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
import os
from urlparse import urlparse, urlunparse
from flask import Flask
from flask import (Flask,
render_template,
request,
redirect)
app = Flask(__name__)
app.debug = os.environ.get("APP_ENV") == "dev"
@app.before_request
def redirect_www():
"""Redirect non-www requests to www."""
urlparts = urlparse(request.url)
if urlparts.netloc == 'www.melanieanderic.us':
urlparts_list = list(urlparts)
urlparts_list[1] = 'melanieanderic.us'
return redirect(urlunparse(urlparts_list), code=301)
@app.route("/")
def index():
return render_template("index.html")
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
app.run(host="0.0.0.0", port=port)