diff --git a/Visual Studio Code Projects/Day-57/__pycache__/post.cpython-312.pyc b/Visual Studio Code Projects/Day-57/__pycache__/post.cpython-312.pyc new file mode 100644 index 0000000..913f6ed Binary files /dev/null and b/Visual Studio Code Projects/Day-57/__pycache__/post.cpython-312.pyc differ diff --git a/Visual Studio Code Projects/Day-57/main.py b/Visual Studio Code Projects/Day-57/main.py new file mode 100644 index 0000000..1f9c500 --- /dev/null +++ b/Visual Studio Code Projects/Day-57/main.py @@ -0,0 +1,37 @@ +from flask import Flask, render_template +import random +import datetime +import requests +from post import Post + + +posts = requests.get("https://api.npoint.io/c790b4d5cab58020d391").json() +post_objects = [] +for post in posts: + post_obj = Post(post["id"], post["title"], post["subtitle"], post["body"]) + post_objects.append(post_obj) + + +app = Flask(__name__) + + +@app.route('/') +def home(): + return render_template("index.html", all_posts=post_objects) + + +@app.route("/post/") +def show_post(index): + requested_post = None + for blog_post in post_objects: + if blog_post.id == index: + requested_post = blog_post + return render_template("post.html", post=requested_post) + +if __name__ == "__main__": + app.run(debug=True) + + + + + diff --git a/Visual Studio Code Projects/Day-57/post.py b/Visual Studio Code Projects/Day-57/post.py new file mode 100644 index 0000000..7e23136 --- /dev/null +++ b/Visual Studio Code Projects/Day-57/post.py @@ -0,0 +1,6 @@ +class Post: + def __init__(self, post_id, title, subtitle, body): + self.id = post_id + self.title = title + self.subtitle = subtitle + self.body = body \ No newline at end of file diff --git a/Visual Studio Code Projects/Day-57/server.py b/Visual Studio Code Projects/Day-57/server.py deleted file mode 100644 index da3213d..0000000 --- a/Visual Studio Code Projects/Day-57/server.py +++ /dev/null @@ -1,35 +0,0 @@ -from flask import Flask, render_template -import random -import datetime -import requests - -app = Flask(__name__) - - -@app.route('/') -def home(): - random_number = random.randint(1, 10) - current_year = datetime.datetime.now().year - return render_template('index.html', num=random_number, year=current_year) - -@app.route('/guess/') -def guess(name): - gender_url = f"https://api.genderize.io?name={name}" - age_url = f"https://api.agify.io?name={name}" - gender_response = requests.get(gender_url) - gender_data = gender_response.json() - gender = gender_data["gender"] - age_response = requests.get(age_url) - age_data = age_response.json() - age = age_data["age"] - return render_template('guess.html', name=name, gender=gender, age=age) - -@app.route('/blog') -def get_blog(): - blog_url = "https://api.npoint.io/c790b4d5cab58020d391" - blog_response = requests.get(blog_url) - all_posts = blog_response.json() - return render_template("blog.html", posts=all_posts) - -if __name__ == "__main__": - app.run(debug=True) \ No newline at end of file diff --git a/Visual Studio Code Projects/Day-57/static/css/styles.css b/Visual Studio Code Projects/Day-57/static/css/styles.css new file mode 100644 index 0000000..8044936 --- /dev/null +++ b/Visual Studio Code Projects/Day-57/static/css/styles.css @@ -0,0 +1,71 @@ +body{ + background: #efeff3; + margin: 0; + font-family: 'Raleway', sans-serif; + -webkit-font-smoothing: antialiased; + color:#212121; +} +.wrapper{ + position: relative; + clear:both; + margin: 0 auto 75px auto; + width: 100%; + overflow: hidden; +} +.top{ + background: #4e89ae; + height: 180px; + border-top: 20px solid #43658b; +} + +.top .title { + width: 700px; + margin: 38px auto 0 auto; +} + +.title h1 { + font-size:24px; + color:#FFF; + font-weight:500; +} + +.content{ + margin: -80px auto 100px; + padding-bottom: 20px; +} + +.card{ + position: relative; + background: #fff; + padding:50px; + width: 600px; + margin: 20px auto 0 auto; + box-shadow: 0 2px 4px rgba(100,100,100,.1); +} + +.card h2 { + font-size:21px; + font-weight:500; +} + +.card h2 a { + color:#CC0000; + text-decoration:none; +} + +.card .text { + color:#212121; + margin-top:20px; + font-size:15px; + line-height:22px; +} + +footer { + position: fixed; + left: 0; + bottom: 0; + width: 100%; + background-color: #43658b; + color: white; + text-align: center; +} \ No newline at end of file diff --git a/Visual Studio Code Projects/Day-57/templates/index.html b/Visual Studio Code Projects/Day-57/templates/index.html index f046c70..e94dd87 100644 --- a/Visual Studio Code Projects/Day-57/templates/index.html +++ b/Visual Studio Code Projects/Day-57/templates/index.html @@ -1,16 +1,29 @@ - - - My Website - + + + Title + + + -

Hello World!

-

{{ 5 * 6}}

-

Random Number: {{ num }}

-Go To Blog +
+
+

My Blog

+
+ + {% for post in all_posts: %} +
+
+

{{ post.title }}

+

{{ post.subtitle }}

+ Read +
+
+ {% endfor %} +
\ No newline at end of file diff --git a/Visual Studio Code Projects/quizzler-app-start/__pycache__/data.cpython-312.pyc b/Visual Studio Code Projects/quizzler-app-start/__pycache__/data.cpython-312.pyc index 21d9ea8..ef695ea 100644 Binary files a/Visual Studio Code Projects/quizzler-app-start/__pycache__/data.cpython-312.pyc and b/Visual Studio Code Projects/quizzler-app-start/__pycache__/data.cpython-312.pyc differ diff --git a/Visual Studio Code Projects/quizzler-app-start/__pycache__/question_model.cpython-312.pyc b/Visual Studio Code Projects/quizzler-app-start/__pycache__/question_model.cpython-312.pyc index fc49915..afc1b9d 100644 Binary files a/Visual Studio Code Projects/quizzler-app-start/__pycache__/question_model.cpython-312.pyc and b/Visual Studio Code Projects/quizzler-app-start/__pycache__/question_model.cpython-312.pyc differ diff --git a/Visual Studio Code Projects/quizzler-app-start/__pycache__/quiz_brain.cpython-312.pyc b/Visual Studio Code Projects/quizzler-app-start/__pycache__/quiz_brain.cpython-312.pyc index 42f5076..40e6852 100644 Binary files a/Visual Studio Code Projects/quizzler-app-start/__pycache__/quiz_brain.cpython-312.pyc and b/Visual Studio Code Projects/quizzler-app-start/__pycache__/quiz_brain.cpython-312.pyc differ diff --git a/Visual Studio Code Projects/quizzler-app-start/__pycache__/ui.cpython-312.pyc b/Visual Studio Code Projects/quizzler-app-start/__pycache__/ui.cpython-312.pyc index 39cd90b..00ded14 100644 Binary files a/Visual Studio Code Projects/quizzler-app-start/__pycache__/ui.cpython-312.pyc and b/Visual Studio Code Projects/quizzler-app-start/__pycache__/ui.cpython-312.pyc differ