A simple URL shortener built with Flask and MongoDB. A deployed version can be viewed here.
- (Optional) Install virtualenv and virtualenvwrapper and create a new environment.
- Run
pip install -r requirements.txt
.
You can either:
- Install MongoDB locally by going here.
or:
- Create a database in the cloud using MongoDB Atlas.
The following properties can be configured:
Name | Purpose | Default |
---|---|---|
DEBUG |
If debug mode is enabled. | False |
ENV |
Environment the app is running in. | production |
MONGODB_DB |
The MongoDB database name. | urlshortener |
MONGODB_HOST |
The MongoDB host name. | 127.0.0.1 |
MONGODB_PASSWORD |
The MongoDB password. | None |
MONGODB_PORT |
The MongoDB port. | 27017 |
MONGODB_USERNAME |
The MongoDB username. | None |
SECRET_KEY |
A secret key used for security. | default secret key |
SERVER_NAME |
The host and port of the server. | 127.0.0.1:5000 |
SESSION_COOKIE_DOMAIN |
The domain match rule that the session cookie will be valid for. | 127.0.0.1:5000 |
SSL |
If the domain has a valid SSL certificate. | True |
To change these properties you can export them as environment variables or create a file instance/config.py
(note
that any environment variables take precedence).
URI style connections are also supported for connecting to MongoDB, just supply the URI as MONGODB_HOST
(note that
URI properties will take precedence).
From your terminal/command prompt run:
./run.py
Then point your browser to http://127.0.0.1:5000/.
For those of you that are interested, the technology used in this project includes:
- Python 3.7
- Flask (Microframework)
- MongoDB and Flask-MongoEngine (Database)
- pytest and Mongomock (Testing)
This project is licensed under the MIT License - see the LICENSE file for details.