Simple Python Flask to make an Rest-API (fe) and MySQL (be)
So I was fooling around with Python and wanted to make a Rest-API as front-end that communicates with a backend database. No problemo you would say? Yes, on my local network this doesn't pose any challenge but you need to consider hosting, and setting it up properly, consider security, SSL certificates and all that good stuff. Didn't want to put a SQL server on the web so looked at various modern ways of doing it without spinning up a containerized cluster. In my search for an integrated solution for my simple sandbox I came across pythonanywhere and it fit my needs perfectly so I'm hosting it there.
- Python 3.x
- MySQL / MariaDB server
- Python-3, Python3-pip
- install all required libraries from the
requirements.txt
. On Linux:
python -m venv .
. bin/activate
pip install -r requirements.txt
You need at least this table for this to work
create table `rest_emp` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`phone` varchar(16) DEFAULT NULL,
`address` text DEFAULT NULL,
PRIMARY KEY(`id`)
);