Created
August 20, 2015 21:54
-
-
Save s-ben/90fd8b61df0db653930a to your computer and use it in GitHub Desktop.
This file contains 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("/hello/<name>") | |
# def hi_person(name): | |
# return "Hello {}!".format(name.title()) | |
@app.route("/jedi/<first_name>/<last_name>") | |
def hi_person(first_name, last_name): | |
jedi_name = last_name[0:3]+first_name[0:2] | |
print type(jedi_name) | |
# return "Your Jedi name is {}!".format(jedi_name.title()) | |
meme_url = "http://apimeme.com/meme?meme=Obi+Wan+Kenobi&top=Your+Jedi+Name+Is&bottom="+jedi_name | |
html = """ | |
<img src="{}"> | |
""" | |
return html.format(meme_url) | |
@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