I have this code:
from flask import (
    Flask,
    render_template
)
import SocketServer
import SimpleHTTPServer
import re
app = Flask(__name__, template_folder="templates")
@app.route('/index', methods=['GET'])
def index():
    return 'Welcome'
@app.route('/write_text_to_file', methods=['POST'])
def write_text_to_file():
    f = open("str.txt", "w+")
    f.write("hello world")
    f.close()
if __name__ == '__main__':
    app.run(debug=True)
EDIT: MY API includes one functionality which is writing a string to local file system by creating this file. What I want to achieve is to be able to pass a string as part of the api request which could be any string and to write the accepted string into a file, now I'm using hard-coded string which get the job done but I want to achieve the ability to send strings dynamically when using this api to write to file.
 
    