2021-01-09 12:25:01 +03:00
|
|
|
from flask import request
|
2022-02-14 11:13:33 +03:00
|
|
|
from app import app
|
2021-01-09 12:25:01 +03:00
|
|
|
import json
|
|
|
|
|
|
|
|
|
2022-02-05 08:56:33 +03:00
|
|
|
@app.route("/variables", methods=["POST"])
|
2021-01-09 12:25:01 +03:00
|
|
|
def variables():
|
2022-02-05 08:56:33 +03:00
|
|
|
assert request.headers["Content-Type"] == "application/json"
|
|
|
|
assert request.headers["Name"] == "Jennifer"
|
|
|
|
assert request.headers["Age"] == "30"
|
|
|
|
assert request.headers["Female"] == "true"
|
|
|
|
assert request.headers["Id"] == "123"
|
|
|
|
assert request.headers["Height"] == "1.7"
|
|
|
|
assert request.headers["A_null"] == "null"
|
2022-09-02 11:50:43 +03:00
|
|
|
assert request.headers["Country"] == "Italy"
|
2023-01-03 19:43:13 +03:00
|
|
|
assert request.headers["Planet"] == "The Earth"
|
2023-01-18 15:47:31 +03:00
|
|
|
assert request.headers["Galaxy"] == "Milky Way"
|
2021-09-10 18:35:23 +03:00
|
|
|
|
2021-01-09 12:25:01 +03:00
|
|
|
s = request.data.decode("utf-8")
|
|
|
|
data = json.loads(s)
|
2022-02-05 08:56:33 +03:00
|
|
|
assert data["name"] == "Jennifer"
|
|
|
|
assert data["age"] == 30
|
|
|
|
assert data["female"] == True
|
|
|
|
assert data["id"] == "123"
|
|
|
|
assert data["height"] == 1.7
|
|
|
|
assert data["a_null"] is None
|
2022-09-02 11:50:43 +03:00
|
|
|
assert data["country"] == "Italy"
|
2023-01-03 19:43:13 +03:00
|
|
|
assert data["planet"] == "The Earth"
|
2023-01-18 15:47:31 +03:00
|
|
|
assert data["galaxy"] == "Milky Way"
|
2022-02-05 08:56:33 +03:00
|
|
|
return ""
|
2023-01-03 19:43:13 +03:00
|
|
|
|
|
|
|
|
|
|
|
@app.route("/variable/country")
|
|
|
|
def country():
|
|
|
|
return "Italy"
|
|
|
|
|
|
|
|
|
|
|
|
@app.route("/variable/planet")
|
|
|
|
def planet():
|
|
|
|
return "The Earth"
|