Table of Contents
I want to play around with some programming techniques (listed below). This repo can be used as examples of using these techniques (although I do not guarantee that they are all the best way to do things as I am just learning). To explore these techniques, I'm creating a simple app and adding just enough complexity to serve as real world examples without it becoming too large. The application is a local website where one can look at images taken by the opportunity rover. As a note, the front-end is not my main concern, most of the skills I want to practice regard the back-end. To maintain my work, I separate different uses of packages into different branches. For example, I have a branch for a Flask front-end and a branch for a Quart front-end (see Branches). See the issues for what I plan to do going forward.
Name | Description |
---|---|
Master | Flask-Sqlalchemy back-end with Quart front-end |
Flask-Frontend | Flask-sqlalchemy back-end with Flask front-end |
Software/techniques/packages used so far. Different branches will have different features and are broken up by branch name.
-
- Testing with Docker: Creating a temporary database in docker and using
the database to test as if on a live server; Creating a redis server and testing against that.
-
- js package management in general
- Async/Await
- Asyncio
- Quart
- Use with Angular
- Blueprints
- AIOHTTP
- aioredis
- pytest-asyncio
- pytest-aiohttp
- pytest-mock
- logging
- Sentry
- Flask + Angular
- Routing to multiple pages handled by Angular through Flask
- Flask
If you want to use this project for your own learning exercises, fork the repo to your own github account and then clone your forked repo to your computer. Make sure docker is installed and running. To get the application running:
If you are not using docker toolbox, set the following environment envariable:
$ export DOCKER_IP='127.0.0.1'
You will need to adjust the volumes in
docker-compose.yml
to your own paths.If using a volume for the opp-web` service (as I do), you have to install the node packages first.
cd
into the directory with thepackage.json
file and then$ yarn install --modules-folder static/node_modules
- To get sentry working, follow the instructions from
Sentry on Premise reproduced
below:
docker volume create --name=sentry-data && docker volume create --name=opportunity-postgres
- Make adjustments to the
.env
file. docker-compose build
- Build and tag the Docker servicesdocker-compose run --rm web config generate-secret-key
- Generate a secret key. Add it to.env
asSENTRY_SECRET_KEY
.docker-compose run --rm web upgrade
- Build the database. Use the interactive prompts to create a user account.- If you never get to the interactive prompt, you need to make room by deleting images and volumes.
- From the top directory
oportunity
, run:
$ docker-compose up
Which will build the images and run the docker containers. If you are using
dockertoolbox, then the host will be 192.168.99.100
, otherwise it will be
the local host 127.0.0.1
. In the examples ahead, I assume the host will
be 127.0.0.1
. In your browser go to http://127.0.0.1:5002/
to
see the home web page:
The first two links allow you to register product types (i.e. EDR, RDR) and
cameras (i.e. pancam). The third link is where you will find images to
register. Clicking Register Image
allows you to register an image with the
local database and then select it for viewing. Selecting an image will display
it on the home page.
Port 5001
is where the API is located to retrieve data from the database.
Page | Toolbox | Docker |
---|---|---|
Home | http://192.168.99.100:5002/ | http://127.0.0.1:5002/ |
Docs | http://192.168.99.100:5005/ | http://127.0.0.1:5005/ |
Swagger | http://192.168.99.100:5004/ | http://127.0.0.1:5004/ |
Sentry | http://192.168.99.100:9000/ | http://127.0.0.1:9000/ |
It's MIT Licensed so feel free to use whatever you want from here. I don't care if you do not cite this repo in published work if you used any of it. Creating the DOI was more of an exercise for myself than anything else.