diff --git a/string_generator.py b/string_generator.py index bfc42f6..d5a49c9 100644 --- a/string_generator.py +++ b/string_generator.py @@ -1,14 +1,46 @@ import secrets import string -def generate_random_subdomain(length=8): - # Choose from alphanumeric characters +def generate_random_string(prefix, length=8): + """Generates a random string with a given prefix.""" alphabet = string.ascii_lowercase + string.digits - # Generate a random subdomain using the chosen alphabet - subdomain = ''.join(secrets.choice(alphabet) for _ in range(length)) - return f"psql-{subdomain}.rideaware.org" - -# Example usage: -random_url = generate_random_subdomain() -print(random_url) # e.g., "a1b2c3d4.rideaware.org" + random_string = ''.join(secrets.choice(alphabet) for _ in range(length)) + return f"{prefix}-{random_string}.rideaware.org" +def main(): + """Prompts the user to select a server type and generates a random URL.""" + while True: + print("Select a server type:") + print("1. PostgreSQL (psql)") + print("2. Redis (redis)") + print("3. RabbitMQ (rabbitmq)") + print("4. Sandbox Web Server (sandbox)") + print("5. Staging Web Server (staging)") + + choice = input("Enter a number (1-5) to select a server type, or 'q' to quit: ") + + if choice == '1': + prefix = "psql" + elif choice == '2': + prefix = "redis" + elif choice == '3': + prefix = "rabbitmq" + elif choice == '4': + prefix = "sandbox" + elif choice == '5': + prefix = "staging" + elif choice == 'q': + break + else: + print("Invalid choice. Please enter a number between 1 and 5.") + continue + + random_url = generate_random_string(prefix) + print(f"Generated URL: {random_url}") + + another = input("Generate do you need another URL? (y/n): ").lower() + if another != 'y': + break + +if __name__ == "__main__": + main()