Created
June 25, 2016 15:46
-
-
Save broschke/bbe4ef86c73ba22c2a1819ca46bb795a to your computer and use it in GitHub Desktop.
Hello World using Flask with Jedi name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from os import environ | |
app = Flask(__name__) | |
@app.route("/") | |
@app.route("/hello") | |
def say_hi(): | |
return "Hello World!" | |
@app.route("/jedi/<first_name>/<last_name>") | |
def jedi_name(first_name, last_name): | |
return last_name[:3]+first_name[:2] | |
@app.route("/hello/<name>") | |
def hello_person(name): | |
html = """ | |
<h1> | |
Hello {}! | |
</h1> | |
<p> | |
Here's a picture of a kitten. Awww... | |
</p> | |
<img src="http://placekitten.com/g/200/300"> | |
""" | |
return html.format(name.title()) | |
if __name__ == '__main__': | |
app.run(host=environ['IP'],port=int(environ['PORT'])) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment