garimasingh128 / awesome-python-projects

📱 ✅ Some awesome projects in python! 📱 ✅
http://garimasingh.me/awesome-python-projects/
MIT License
1.04k stars 297 forks source link

Update app.py #159

Closed anandcharukesan closed 1 year ago

anandcharukesan commented 1 year ago

I made the following corrections and modifications to the code along with descriptions for each change:

  1. Removed unnecessary imports:

    • Removed the from __future__ import with_statement import as it's not needed in Python 3.
    • Removed unused imports like contextlib and urllib2.
  2. Simplified URL shortening logic:

    • Removed the unnecessary use of contextlib.closing and directly used the with urlopen context manager to make the HTTP request to the TinyURL service.
  3. Added command-line argument checking and usage message:

    • Checked if there are command-line arguments provided before running the main() function.
    • Provided a usage message to instruct the user to provide URLs as command-line arguments when running the script.
  4. Modified the code to allow user input for URLs:

    • Changed the script to interactively prompt the user to enter URLs one by one using the input function.
    • Added the ability for the user to type 'q' and press Enter to exit the URL entry loop.

These changes make the code more user-friendly and simplified while ensuring that it handles URL input from the user as well.

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Test Configuration:

Checklist: