I'm trying to learn Flask with python, and I just can't find the best example for my use case.
I'm building an app that gets rest API request:
curl -i -H "Content-Type: application/json" -X POST -d '{"domain_name":"vangus.com"}' http://serverip:5000/api/v1/domains
This api request gives domain name to the app, for it to run some code with this domain.
with that argument the function supposed do do some stuff in the server (nginx), currently it doesn't matter what. I can't figure out the logic how that supposed to work.
This is my code:
from flask import Flask, request, jsonify
import json
import subprocess
import sys
import re
from datetime import datetime
from pathlib import Path
app = Flask(__name__)
@app.route('/api/v1/domains/<domainarg>', methods=['POST'])
def add_domain(domain_name):
# some python code that creates nginx configuration for that domain
???
How exactly am i saving the "argument" i got from the api post request in a variable?