This post will be a recap of how I did my assignment for tele3118 as a future reference.
It basically asks you to design a local server to display JSON data acquired from a remote server using UDP socket programming.
I did the first part which is sokcet programming with ease as it only requires to pull a series of string from remote server. The only problem I met was initially the test server was written in python2 so that it won’t recognized the message from client but it was solved by modifying the python file of test server.
For the second part it wasn’t as easy as google for a few examples. It consists of two task. First is to print out the list of names contained in the student list acquired from part one. Second is to design REST api for the user to pull specific student’s mark by entering the name.
It is quite self explanatory that if I typed localhost/api/studentlist, it will direct me to the page with all the names of students. And if I typed localhost/api/studentmark/Josh, it will show me the mark that associates with Josh.
This assignment also consists of a bonus part where a front-end interface is required rather then the plain webpage. So I used a html example of someone else for the mark searching part. For the simplicity of this post, I will just post the html screen shot of the final web page.
from flask import Flask, request,render_template,url_for