# HW5: Flask and App Inventor

Hi all,

For this homework, I would like you all to connect a flask-based web application with an android front-end as shown in class. Flask is a Python-based web app framework. An even more popular one is django. But comparing to django, Flask has less steep learning curve and so I chose flask for this class instead. You can follow this to install flask or simply run

sudo pip install flask


A simple flask app is written and available here. You can test run it with

python echo_get.py


By default, the app should be setup at port 5000. You can now try it on your browser. Open 127.0.0.1:5000 (or use the ip address of your ubuntu box), you should see a page with an input box and a button. If you type something in the box and push the button, what you typed will simply be echoed back.

Now, try to connect it with app inventor, you need to use the web component (under “connectivity”) to establish connection with the server.

A sample app is as shown above. Note that you should change the ip 10.130.142.90 to the actual ip of your server. Now, if everything is working great, you should get an echo message when you press the button in your android app.

For the HW, I just want you to make a slight adjustment of your server code. You can do more of course. But for the minimum, please echo the reverse of the original text. For example, “hello all” will become “lla olleh”. As usual, please email me a video capture for your submission. You are encouraged to add more bells and whistles to this app. You may also consider it as a base for your project if you are interested in this direction.

And as I mentioned in class, I would also like you to do some exercises for the queueing things. So please also submit a solution (you can email me photos) for the following question.

The arrival rate to a router is 100 packets per second. And the router will always process a packet with exactly 5ms. And let's assume that the queue inside of the router has infinite length.

1. What is the probability that we see exactly 100 packets arrived in a second?

2. What is the probability that we have less than 5 packets arrived in a second?

3. What is the probability that the interarrival time is more than 20 ms?

4. What is the average wait time of a packet?

5. What is the average delay?

6. Assuming that now half of the incoming packing will have length doubling of the original and the router will need double amount of the time to process them. In other words, now 50% of the packets will need 10ms processing time and the remaining 50% need 5 ms. What will the average wait time and average delay become?

Cheers,

Sam

p.s. I always wanted to say it in class but I kept forgetting to mention that… I can see quite a few of you have put some extra effort on the HW and I really appreciate that. Therefore, I incline to give some small bonuses to really well-done HW (starting from the first one). Potentially these bonuses could contribute a tie-breaker to your grade. But note that while there is still no penalty for late (hopefully not outrageously late) HW, a bonus will only be given to HW that was submitted on time.