If you just want a simple server, Flask will be better.
First, install Flask:
pip install Flask
If you want more detaild instructions, you can check that tutorial: https://flask.palletsprojects.com/en/1.1.x/installation/
This is the basic template of a the Flask app that you want:
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/testing', methods=['GET'])
def testing():
mobile = request.args.get('mobile')
operator = request.args.get('Operator')
time_stamp = request.args.get('Time_Stamp')
print(mobile)
print(operator)
print(time_stamp)
return 'Success!'
This code will wait for a GET request on yourdomain.com/testing, and will print the given parameters "mobile", "Operator" and "Time_stamp".
To run:
- Save it in a .py file, make sure not to call it
flask.py
, so it will not conflict with Flask.
- Run
export FLASK_APP=hello.py
on linux, or set FLASK_APP=hello.py
on Windows (CMD). make sure to replace hello.py
with the name that you called your program in the previous step.
- Run
flask run
.
Now, your server will listen on http://localhost:5000
.
Enjoy!