I am targeting to make an speedtest application, but without using any functions such as .download, .upload or .ping, also speedtest library not allowed. I am thinking to get ping by shell commands but i do not know others. I am doing this project on aws cloud server, I am using ec2 just for information.
The output should be like: download: upload: ping:
from flask import Flask, render_template, request
from views import views
import requests
import time
import speedtest
app = Flask(__name__)
app.register_blueprint(views, url_prefix = "/views")
@app.route('/')
def index():
return render_template('index.html')
@app.route('/measure', methods=['POST'])
def measure():
if request.method == 'POST':
########BEGIN CODE Between these sections will be deleted because .download etc functions
########are not all allowed
st = speedtest.Speedtest()
download_speed = st.download() / 10**6 # Convert to Mbps
upload_speed = st.upload() / 10**6 # Convert to Mbps
ping = st.results.ping
########END CODE
return render_template('measure.html', download_speed=download_speed, upload_speed=upload_speed, ping=ping)
if __name__ == '__main__':
app.run(debug=True, port=8000)
I am very open for any correction or any idea for this problem. We have to make an speedtest application without using functions as mentioned before and we do not use speedtest library. I am not sure but requests may be used for this problem. (but not sure)