Skip to content

Instantly share code, notes, and snippets.

@sinar96
Last active July 28, 2016 12:42
Show Gist options
  • Save sinar96/c5901c23d9da3f44a197b9da656bbfb7 to your computer and use it in GitHub Desktop.
Save sinar96/c5901c23d9da3f44a197b9da656bbfb7 to your computer and use it in GitHub Desktop.
Code ini akan membantu kalian untuk memahami perbedaan code pada Static Route dan Dynamic route
from flask import Flask
#create the application object
app = Flask(__name__)
app.config.from_object('config')
database.init_app(app)
@app.route("/")
def main():
# Static Route
main = Main.query.all()
return render_template("main.html", **locals())
@app.route("/<int:id>")
def show_content(id):
# Dynamic Route
main = Main.query.get(id)
if not main:
abort(404)
return render_template("mainpost.html", **locals())
if __name__ == "__main__":
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment