Flask API Example
An example project showing a simple endpoints like a login/logout function and maybe some others.
How to use:
- Open up your IDE (or use CMD prompt and go to the directory where this is)
- In the terminal, run pip3 install -r requirements.txt
- Run main.py to start the flask development server.
- Navigate to on your browser.
- The default login for the test account is
- Username: test_user
- Password: password
This doesn’t use a database. It’s literally a python dictionary holding the data, so if you restart the main.py, the session you have will die. Obviously once we’re using a MongoDB the session will be stored there and not deleted constantly.
If you have any problems just let me know. It’s a complicated to thing to look at your first glance, but it gets really easy. You’ll definitely see REST or other types of JSON APIs in the future. It’s really common with massive companies so they can just use a basic API to hook their sites, phone apps, and other devices to avoid wasting resources reinventing the same functions they’ve already got.
I’m free to help most of the time and if you just want to toss the API work onto me, I’m fine with. I love this stuff.
The code should be well commented, but if anything is confusing please say. At the very least you should get an idea. If you can’t launch it I can just show you on a screenshare or in person.
test.py is an example using the requests module to interact with the API. The HTML & JS should work fine though.