Python to handle HTTP Request
up vote
0
down vote
favorite
Sorry, I am a new to Python.
Task:
There are some HTML pages, which calls a URL with some parameters. The Python script should be able to detect the html request and based on the parameter execute function
Webpages are present in /var/www/html/
Example: From index.html, if a button is pressed, it calls a URL - bcast.xml?mode=1 or bcast.xml?mode=2
Now there is no file bcast.xml
So the Python script should basically be constantly looking for any request from the web server (apache) and if the file name is bcast.xml, it should look for mode value and based on that it should execute some functions
Question:
I have no clue where to start even Google it, What should I be searching for or if anyone knows of a solution that would be great.
Thanks in advance
python html web
add a comment |
up vote
0
down vote
favorite
Sorry, I am a new to Python.
Task:
There are some HTML pages, which calls a URL with some parameters. The Python script should be able to detect the html request and based on the parameter execute function
Webpages are present in /var/www/html/
Example: From index.html, if a button is pressed, it calls a URL - bcast.xml?mode=1 or bcast.xml?mode=2
Now there is no file bcast.xml
So the Python script should basically be constantly looking for any request from the web server (apache) and if the file name is bcast.xml, it should look for mode value and based on that it should execute some functions
Question:
I have no clue where to start even Google it, What should I be searching for or if anyone knows of a solution that would be great.
Thanks in advance
python html web
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Sorry, I am a new to Python.
Task:
There are some HTML pages, which calls a URL with some parameters. The Python script should be able to detect the html request and based on the parameter execute function
Webpages are present in /var/www/html/
Example: From index.html, if a button is pressed, it calls a URL - bcast.xml?mode=1 or bcast.xml?mode=2
Now there is no file bcast.xml
So the Python script should basically be constantly looking for any request from the web server (apache) and if the file name is bcast.xml, it should look for mode value and based on that it should execute some functions
Question:
I have no clue where to start even Google it, What should I be searching for or if anyone knows of a solution that would be great.
Thanks in advance
python html web
Sorry, I am a new to Python.
Task:
There are some HTML pages, which calls a URL with some parameters. The Python script should be able to detect the html request and based on the parameter execute function
Webpages are present in /var/www/html/
Example: From index.html, if a button is pressed, it calls a URL - bcast.xml?mode=1 or bcast.xml?mode=2
Now there is no file bcast.xml
So the Python script should basically be constantly looking for any request from the web server (apache) and if the file name is bcast.xml, it should look for mode value and based on that it should execute some functions
Question:
I have no clue where to start even Google it, What should I be searching for or if anyone knows of a solution that would be great.
Thanks in advance
python html web
python html web
edited Nov 14 at 2:22
Homam
192
192
asked Nov 13 at 22:54
Hari Haran T
82
82
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
I suggest using a framework to handle this. Check out flask.
Python Flask how to get parameters from a URL?
Also, for Flask to communicate with Apache, you'll need to use mod_wsgi.
add a comment |
up vote
0
down vote
The easiest way is to use some framework, for example Flask.
Install it using pip:
pip install flask
Use:
from flask import Flask, request
app = Flask(__name__)
@app.route("/api_url/", methods=["POST"])
def handle_api_requests():
return str(request.form)
app.run()
In handle_api_requests function you can describe any logic you need have to handle api requests from your frontend.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I suggest using a framework to handle this. Check out flask.
Python Flask how to get parameters from a URL?
Also, for Flask to communicate with Apache, you'll need to use mod_wsgi.
add a comment |
up vote
0
down vote
I suggest using a framework to handle this. Check out flask.
Python Flask how to get parameters from a URL?
Also, for Flask to communicate with Apache, you'll need to use mod_wsgi.
add a comment |
up vote
0
down vote
up vote
0
down vote
I suggest using a framework to handle this. Check out flask.
Python Flask how to get parameters from a URL?
Also, for Flask to communicate with Apache, you'll need to use mod_wsgi.
I suggest using a framework to handle this. Check out flask.
Python Flask how to get parameters from a URL?
Also, for Flask to communicate with Apache, you'll need to use mod_wsgi.
answered Nov 13 at 23:00
tr0yspradling
1831619
1831619
add a comment |
add a comment |
up vote
0
down vote
The easiest way is to use some framework, for example Flask.
Install it using pip:
pip install flask
Use:
from flask import Flask, request
app = Flask(__name__)
@app.route("/api_url/", methods=["POST"])
def handle_api_requests():
return str(request.form)
app.run()
In handle_api_requests function you can describe any logic you need have to handle api requests from your frontend.
add a comment |
up vote
0
down vote
The easiest way is to use some framework, for example Flask.
Install it using pip:
pip install flask
Use:
from flask import Flask, request
app = Flask(__name__)
@app.route("/api_url/", methods=["POST"])
def handle_api_requests():
return str(request.form)
app.run()
In handle_api_requests function you can describe any logic you need have to handle api requests from your frontend.
add a comment |
up vote
0
down vote
up vote
0
down vote
The easiest way is to use some framework, for example Flask.
Install it using pip:
pip install flask
Use:
from flask import Flask, request
app = Flask(__name__)
@app.route("/api_url/", methods=["POST"])
def handle_api_requests():
return str(request.form)
app.run()
In handle_api_requests function you can describe any logic you need have to handle api requests from your frontend.
The easiest way is to use some framework, for example Flask.
Install it using pip:
pip install flask
Use:
from flask import Flask, request
app = Flask(__name__)
@app.route("/api_url/", methods=["POST"])
def handle_api_requests():
return str(request.form)
app.run()
In handle_api_requests function you can describe any logic you need have to handle api requests from your frontend.
answered Nov 13 at 23:06
Artsiom Praneuski
1,004312
1,004312
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290734%2fpython-to-handle-http-request%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown