I am using pythonanywhere.com to run my code , I am using a post form in the index.html and I have a log.txt file and I want to log the info ip address of the user and below that I want the post form . https://ibb.co/esiJhJ
            Asked
            
        
        
            Active
            
        
            Viewed 922 times
        
    1 Answers
1
            You can get IP address from request.remote_addr and using python default logging library you can easily write the ip into a file.
code example
import logging
from flask import request
# configure your logging and let the file name is text.log
logging.basicConfig(filename='text.log', 
                    level=logging.INFO)
@app.route("/your_path", methods=["POST"])
def example():
    logging.info("ip: {}".format(request.remote_addr))
you can also modify the write format. For more details visit here
 
    
    
        Shaon shaonty
        
- 1,367
- 1
- 11
- 22