Responses in Frost allows you to send back data & forms to the requests.
Methods are allow only indicated methods for a route request. we have 4 type of Methods that called: "GET", "POST", "PUT", "DELETE". the default method is GET.
Example:
from pythonfrost import route, Server
@route("/", methods=["POST"])
def home():
return "this is only For POST Method"
Server()
this function will allow us to send JSON to client.
Example:
from pythonfrost import route, Server, send_json
@route("/")
def home():
return send_json({"message":"this is a json"})
Server()
by default the status will be 200. we can set it our self by setting the function parameter.
Example:
@route("/")
def home():
return send_json({"message":"this is a json"}, status=404)
this fucntion allow you to Redirect to any route that you want.
Example:
from pythonfrost import route, Server, redirect
@route("/")
def home():
return redirect("/safe")
@route("/safe")
def safe():
return "Hello!"
Server()
you can get any form from client just by inserting "form_data" to your function parameter
@route("/", methods=["POST"])
def getform(form_data):
data = form_data.get("YOUR_DATA_FORM_NAME_HERE")
return data