INF397 Full Stack Technologies View Schedule Print

Backend Overview

Static web server

Return only the contents of files

CGI Protocol

Common Gateway Interface - run a program to generate a response

Application Server

Language/Platform specific http implementations

  • CGI - PHP
  • webContainer - Java
  • USAPI - dotNet
  • uWSGI - Python
  • libUV - node.js

Serverless

Execute code on shared cloud infrastructure

CLEAN application structure

CLEAN application structure

  • Use-cases encapsulate Domain/Business logic
  • Use-cases have input & output interfaces
  • Controllers initiate use-cases
  • Presenters observe use-case results

http server in node.js


          /* server.js */
          var http = require('http'),
              server = http.createServer(function (req, res) {
                  //server executes callback on every connection
                  res.send('Hello Web!');
          });

          //start the server on port 8080
          server.listen(8080);
          
run the server from the console

      node server.js
  

Routing

  1. Parse the URL
  2. Select the most appropriate response strategy
  3. Execute it with on the request parameters

Express for Node.js


    //create new tasks
     srv.post('/task', (req, res) => {
       task = tasks.createTask(req.params);
       res.json(task);
     });

     //get an existing task
     srv.get('/task/:id', (req, res) => {
       res.json(tasks.get(req.params.id));
     });

     //toggle task done
     srv.put('/task/:id/toggle', (req, res) => {
       const task = tasks.get(req.params.id);
       task.done = !task.done;
       res.json(task);
     });
  

Flask for Python


    @app.route('/')
    def show_entries():
      db_cursor = db.execute('SELECT title, text FROM entries')
      entries = db_cursor.fetchall()
      return render_template('show_entries.html', entries=entries)

    @app.route('/add', methods=['POST'])
    def add_entry():
      if not session.get('logged_in'):
        abort(401)
      db.execute('INSERT INTO entries (title, text) VALUES (?, ?)',
                      [request.form['title'], request.form['text']])
      db.commit()
      flash('New entry was successfully posted')
      return redirect(url_for('show_entries'))
  

Vert.x for Java


      public static void main(String[] args) {
        Router router = Router.router(vertx);

        router.get("/products").handler(this::handleListProducts);

        vertx.createHttpServer()
          .requestHandler(router::accept)
          .listen(8080);
      }

      private void handleListProducts(RoutingContext routingContext) {
        JsonArray results = new JsonArray();

        products.forEach((k, v) -> results.add(v));

        routingContext.response()
          .putHeader("content-type", "application/json")
          .end(results.encodePrettily());
      }
    

Security

  • System take-ove (rootkit)
  • Code execution (SQL injection)
  • Data leak / loss (Ransomware)
  • Malicious communication (CSRF, DDOS)

Course Schedule:

week 1 03.02.2017 History of the web Fullstack Principles Development Processes Agile Processes DevOps Basics Git
week 2 10.02.2017 Frontend Overview Backend Overview Network Overview Testing JavaScript Overview JavaScript Tooling
week 3 17.02.2017 Web Architectures RESTful principles SOLID principles Web Components Continuous Integration
week 4 24.02.2017 Databases basics Using APIs Deployment Automation Monitoring In-class project consultations
week 5 17.03.2017 Project presentations
Final Test
Course Retrospective and Q&A