Description:
Blog app, which can be accessed from a website and via an API from a Swift Application. You can create an account , read and write posts. The database is managed by Flask and sqlite3 in Python.
Why I have built this project:
Until this project I have always used Firebase as the backend for my iOS apps. I wanted to try something new and researched about building a database with Python and the Tutorial from flask was my starting point. Instead of just building the application from this tutorial, I tried to combine it with my own iOS app. I achieved my goal of creating my own Database and linking it to a Website and an iOS app so that both application are dealing with the same data.
Download:
All commands are marked with ' '.
- Download it via Github and open the DatabaseWithWebsite Folder in your IDE
- Create a Virtual Environment. It worked for me with python3 -m venv * (* is the name of your venv)
- Activate the venv. It worked for me with '. */bin/activate'
- Install Flask with 'pip install flask'
- These commands are needed to run the server:
'export FLASK_APP=database'
'flask init-db'
'flask run'
Your Server is now running and you can access it on your localhost If you want to use it in production you need a production server. - To Start the swift app you need to open the folder SwiftBlogApp in Xcode and press the build button. When you want to use another server, you need to provide the correct url
More explanations are in the code.
Usecases:
You can run this application on your own server and let other people signup and communicate with each other.
Credits:
This tutorial from flask helped me a lot. You will recognize some lines of code from the tutorial ;)
https://flask.palletsprojects.com/en/2.0.x/tutorial/
This video from iOS Acedemy helped me to understand the functionality of POST Requests in Swift https://www.youtube.com/watch?v=o3Rkg6WmZoY&t=497s