Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. from flask import Flask
  2.  
  3. app = Flask(__name__)
  4.  
  5. @app.route("/")
  6. def main():
  7. return "Hello world"
  8.  
  9.  
  10. def generate_style(class_name, color):
  11. style = f"<style> .{class_name} {{ background-color: {color} }}</style>"
  12. return style
  13.  
  14. @app.route("/user/<id>")
  15. def user(id):
  16. style_tag = generate_style("red", "red")
  17. whole_page = """<html><head>{}</head><body><div class="red">Hello user number {}</div></body></html>""".format(style_tag, id)
  18. return whole_page
  19.  
  20. if __name__ == "__main__":
  21. app.run(debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement