Hey there! 👋 This is my little QR code generator built while exploring Rust. It's simple but gets the job done!
So, I was learning Rust and thought, "Hey, wouldn't it be cool to make QR codes?" That's how this project was born! It's a web service that turns URLs into QR codes. Nothing fancy, but I had fun building it and learned a ton about Rust web development along the way! 🎉
- 🎨 Makes QR codes as SVGs (they look super crisp!)
- 🔑 Has a simple API key setup (my first attempt at auth!)
- 📝 Logs stuff so you can see what's happening
- 🌐 Works with other websites (CORS stuff that I finally figured out 😅)
- ⚡️ Pretty quick (thanks, Rust! 🦀)
- Rust (latest stable)
- Cargo (comes with Rust)
- A few minutes of free time ⏰
- Grab the code:
git clone https://github.com/yourusername/qr-service.git
cd qr-service
- Set up your secret stuff:
echo "API_KEY=whatever_you_want" > .env
echo "PORT=8080" >> .env # optional, defaults to 8080
- Let it rip!
cargo run
Just send a GET request to:
GET /generate?url=<the-url-you-want-as-qr>
Don't forget your API key (the one you put in .env):
X-API-Key: whatever_you_put_in_env
Try this in your terminal:
curl -X GET "http://localhost:8080/generate?url=https://example.com" \
-H "X-API-Key: your_secret_key"
You'll get back a nice SVG QR code! 🎨
Just hit the root URL to make sure it's alive:
curl http://localhost:8080/
# Should say "Hello, world!" if everything's working
Here's what I'm using (had to learn all these! 📚):
- Rocket: Makes web stuff in Rust actually fun
- qrcode: The real MVP - turns URLs into QR codes
- dotenv: Handles the secret stuff
- env_logger: Helps see what's going on
- QR codes are 200x200 pixels (seemed like a good size!)
- They're black and white (keeping it simple!)
- If something goes wrong, you'll get:
- 400 if you forgot the API key (oops!)
- 401 if the API key is wrong (double oops!)
- 500 if the URL breaks something (triple oops!)
I'm still learning Rust, so I'd love any help or suggestions! If you spot something that could be better (I'm sure there's lots!):
- Fork it
- Make your changes
- Send me a PR
- Teach me something new! 🎓
MIT Licensed - use it, change it, share it! Just don't blame me if something breaks 😅
If this helped you learn something about Rust or QR codes, feel free to give it a star!
Built with 🦀 Rust while drinking too much ☕ coffee
PS: If you're also learning Rust, drop by the Issues tab and say hi! Always happy to meet fellow learners.