Step 1: Fork the Repository
Visit the repository URL: thirdygayares/keriderya-api
In the top-right corner, click the Fork button to create a copy of the repository under your GitHub account.
Step 2: Set up a PythonAnywhere Account
Go to pythonanywhere.
Sign up for a new account if you don’t already have one.
Once logged in, go to your account settings and note down your PythonAnywhere username and password (make sure you store these in Excel for future reference).
3. List Your Credentials on Excel
Create an Excel sheet with your credentials for the MySQL database and other necessary configurations like environment variables.
4. Add New Bash Consoles
Go to the Consoles tab in PythonAnywhere.
Click on the Bash option to open a new Bash console.
5. Clone the Repository
In the Bash console, clone your forked repository using Git. You will need to replace the URL with the one for your fork.
git clone https://github.com/yourusername/keriderya-api.git
cd keriderya-api
6. Set Up the Database in MySQL Console
Go to the Databases tab.
Create a new MySQL database. For example, name it
keriderya_db
.Once the database is created, note the database name, username, and password for later use.
7. Create a Virtual Environment
In the Bash console, create a virtual environment for the project.
python3.10 -m venv venv
8. Activate Virtual Environment
Activate the virtual environment.
source venv/bin/activate
9. Install requirements
pip install -r requirements.txt
10. Configure the Environment Variables
Create a .env
file in the root of your project and add the necessary environment variables such as database credentials and other configuration details.
nano .env
Step 9. Edit config.py
and Remove the Certificate
Open config.py
using nano
editor:
nano config.py
Look for any SSL certificate or configuration references and remove them, as they may not be needed on PythonAnywhere’s default configuration.
Step 10. Run Flask DB Upgrade
Run the following Flask command to apply database migrations:
python -m flask db upgrade
Step 11. Check MySQL Tables
Check that the database tables were created successfully by entering the MySQL console:
Enter your MySQL password when prompted, and then check the tables:
SHOW TABLES;
Step 12. Go to the Web Tab
In your PythonAnywhere dashboard, go to the Web tab.
Step 13. Create a New Web App
Click Add a new web app.
Choose Flask for the web framework.
Select Python 3.10 for the Python version.
/home/RonaDecio14/keriderya-api/run.py
Step 14. Path Virtual Environment
Under the Virtualenv section, enter the path to your virtual environment (for example, /home/your-username/keriderya-api/venv
).
This will ensure that PythonAnywhere uses your virtual environment for the web app.
Step 15. Edit WSGI File
In the Web tab, scroll down to the WSGI configuration file section and click the link to open the WSGI configuration file.
Edit the file to include the correct paths to your Flask app and virtual environment. Example WSGI setup:
16. Reload the Web App
Once you've made the changes, go back to the Web tab and click Reload to apply the changes.
Step 17. Test the Web App Using Postman
18. Add dummy data
{
"username": "meow",
"email": "meow@xample.com",
"password": "meow",
"role": "user"
}
POST/users
GET all Users
Get User by UUID in Postman
UPDATE/users
Check Database
Delete/users
Check Database Again
Pythonanywhere Link
https://ronadecio14.pythonanywhere.com/