First we create a schema, and make a database
schema.sql looks like this.
Before running that you'll need to create the initial db which can be done via the command line in the same folder as your flaskr.py file
sqllite3 flaskr.db < schema.sql
at the command line type python
>>This *should* create the first intance of the database.
from flaskr import init_db
finally when you're ready, start the following file with
sudo python flaskr.py
So here is the code to run for the simple server(flaskr.py)
So if you want different data stored off, you can change your schema, and the insert/select statement.
If you don't care about storing data, (you just want to perform actions) you can ignore most of the sql related items, and just read the data and perform whatever operation
Now that we have a working app.
If you want to see the app get "data"
go to your browser and type in your ip address (if you did your IP and port as your values) and the data to send for example:
So now on your python script
request.args.get('title') should pull out "you rock" and
request.args.get('text') should pull out "this tutorialhopefullyhelps"
This is the site that I had most of my tutorial from:
And the last example some came from here:
Post a Comment