from flask import Flask, redirect, request
app = Flask(__name__)
# Dictionary to store link clicks
link_clicks = {}
@app.route('/track/
')
def track_link(link):
# Increment the link click count
link_clicks[link] = link_clicks.get(link, 0) + 1
# Redirect to the actual link
return redirect(link)
@app.route('/stats/')
def link_stats(link):
# Return the number of clicks for the link
return f"The link {link} has been clicked {link_clicks.get(link, 0)} times."
if __name__ == '__main__':
app.run(debug=True)
0 Comments