Advertisement
AtEchoOff

Flask Boilerplate Code

Aug 3rd, 2024 (edited)
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. ----------------------------------------------------------------
  2. app.py
  3.  
  4. from flask import Flask, render_template, request, session, make_response, redirect
  5.  
  6. app = Flask(__name__)
  7. app.secret_key = "super secret key"
  8.  
  9.  
  10. @app.route('/')
  11. def index():
  12. return render_template("index.html")
  13.  
  14. if __name__ == '__main__':
  15. import os
  16. HOST = os.environ.get('SERVER_HOST', 'localhost')
  17. try:
  18. PORT = int(os.environ.get('SERVER_PORT', '5555'))
  19. except ValueError:
  20. PORT = 5555
  21. app.run(HOST, PORT, debug=True)
  22.  
  23.  
  24. ----------------------------------------------------------------
  25. index.html
  26.  
  27. <!DOCTYPE html>
  28. <html>
  29. <head>
  30. <meta charset='utf-8'>
  31. <meta http-equiv='X-UA-Compatible' content='IE=edge'>
  32. <title>My Portfolio!</title>
  33. <meta name='viewport' content='width=device-width, initial-scale=1'>
  34. <link rel='stylesheet' type='text/css' media='screen' href='/static/style.css'>
  35. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  36. <script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/3.0.1/js.cookie.min.js"></script>
  37. <script src="/static/index.js"></script>
  38.  
  39. </head>
  40. <body>
  41. <div id="top">
  42. <h1>Hello world!</h1>
  43.  
  44. </div>
  45. <div style="text-align: center;">
  46. <h3>Hello! This is the index page of my website!</h3>
  47. </div>
  48. </body>
  49. </html>
  50.  
  51. ------------------------------------------------------------------
  52. style.css
  53.  
  54. #top {
  55. background-color: blanchedalmond;
  56. border: 2px solid black;
  57. box-shadow: 0px 5px 5px black inset;
  58. text-align: center;
  59. margin: 10px;
  60. }
  61.  
  62. body {
  63. text-align: center;
  64. background-color: navajowhite !important;
  65. }
  66.  
  67. * {
  68. font-family:
  69. 'Arial';
  70. }
  71.  
  72. .wrapper {
  73. width: 20%;
  74. padding: 10px;
  75. border-radius: 5px;
  76. background: #f8ca85;
  77. margin: auto;
  78. }
  79.  
  80. form {
  81. margin: 25px auto;
  82. }
  83.  
  84. .btn {
  85. width: auto;
  86. border: none;
  87. margin-top: 5px;
  88. color: white;
  89. background-color: #3b5998;
  90. border-radius: 5px;
  91. padding: 12px;
  92. }
  93.  
  94. .form-control {
  95. width: 50%;
  96. }
  97.  
  98. .error {
  99. color: red;
  100. text-align: center;
  101. }
  102.  
  103. .valid {
  104. color: green;
  105. }
  106.  
  107. ul {
  108. width: 30%;
  109. margin: auto;
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement