diff --git a/server.py b/server.py index 873d917..9939bdc 100644 --- a/server.py +++ b/server.py @@ -1,9 +1,51 @@ -from models import user, events -from apis import sbb +from flask import Flask, render_template, request, jsonify, make_response, request +import random +import time -SBB = sbb.SBBWrapper() +from flask.templating import render_template_string -ret = SBB.wrapper.locations.get(params={"name":"Zürich"}) -print(ret[:3]) +app = Flask(__name__) -# def load_events() \ No newline at end of file +heading = "Lorem ipsum dolor sit amet." + +content = """ +Lorem ipsum dolor sit amet consectetur, adipisicing elit. +Repellat inventore assumenda laboriosam, +obcaecati saepe pariatur atque est? Quam, molestias nisi. +""" + +db = list() # The mock database + +posts = 500 # num posts to generate + +quantity = 20 # num posts to return per request + + +@app.route("/") +def index(): + """ Route to render the HTML """ + context = { + "title" : f"Event title {id}", + "image_name" : "fallback.jpg", + "star_rating" : random.randint(1,4), + "reviews" : random.randint(10,30), + "user" : "Remy" + } + return render_template("base.html", context=context) + + + +@app.route("/get_event") +def get_event(): + id = request.args.get("id", type = int) + context = { + "title" : f"Event title {id}", + "image_name" : "fallback.jpg", + "star_rating" : random.randint(1,4), + "reviews" : random.randint(10,30), + "user" : "Remy" + } + return render_template("event_card.html", context=context) + + +app.run(port=8000, debug=True) \ No newline at end of file diff --git a/static/SBB-Logo.png b/static/SBB-Logo.png new file mode 100644 index 0000000..b5d9933 Binary files /dev/null and b/static/SBB-Logo.png differ diff --git a/static/custom-bootstrap-override.css b/static/custom-bootstrap-override.css new file mode 100644 index 0000000..b64962c --- /dev/null +++ b/static/custom-bootstrap-override.css @@ -0,0 +1,9 @@ +.bg-primary .btn-primary .btn-primary:hover{ + border-color: red; + background-color: red !important; + +} + +* { + border-radius: 0 !important; +} \ No newline at end of file diff --git a/static/fallback.jpg b/static/fallback.jpg new file mode 100644 index 0000000..3f1f802 Binary files /dev/null and b/static/fallback.jpg differ diff --git a/static/index.js b/static/index.js new file mode 100644 index 0000000..63a22f5 --- /dev/null +++ b/static/index.js @@ -0,0 +1,33 @@ +var currentscrollHeight = 0; +var count = 0; +jQuery(document).ready(function ($) { + for (var i = 0; i < 8; i++) { + callData(count);//Call 8 times on page load + count++; + } +}); +$(window).on("scroll", function () { + const scrollHeight = $(document).height(); + const scrollPos = Math.floor($(window).height() + $(window).scrollTop()); + const isBottom = scrollHeight - 100 < scrollPos; + if (isBottom && currentscrollHeight < scrollHeight) { + //alert('calling...'); + for (var i = 0; i < 6; i++) { + callData(count);//Once at bottom of page -> call 6 times + count++; + } + currentscrollHeight = scrollHeight; + } +}); +function callData(counter) { + $.ajax({ + type: "GET", + url: "http://localhost:8000/get_event?id=" + counter, + dataType: "html", + success: function (result) { + //alert(result[0]); + $(result).appendTo('.list'); + }, + error: function (result) {} + }); +} diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..cde94ea --- /dev/null +++ b/templates/base.html @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + +{% include "sidebar.html" %} +
+

Physical doodling

+
+

Welcome {{ context.user }}

+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/templates/event_card.html b/templates/event_card.html new file mode 100644 index 0000000..f5c102d --- /dev/null +++ b/templates/event_card.html @@ -0,0 +1,24 @@ +
+ + ... + +
+
+
{{ context.title }}
+
    +
  • Total duration: {{context.duration }}
  • +
  • {{ context.location }}
  • +
      + + {% for n in range(context.star_rating) %} + + {% endfor %} + {% for n in range(5 - context.star_rating) %} + + {% endfor %} + + {{ context.reviews }} reviews +
    +
+
+
\ No newline at end of file diff --git a/templates/sidebar.html b/templates/sidebar.html new file mode 100644 index 0000000..e183096 --- /dev/null +++ b/templates/sidebar.html @@ -0,0 +1,16 @@ +