-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Flask REST API #16
base: master
Are you sure you want to change the base?
Flask REST API #16
Conversation
Good work, I'll give this a more thorough review later. |
FYI the free text search only works for the backpagecontent table. Ill have to figure out how to join tables so you can search with phone numbers, email, etc. |
Did another look over. Besides your comments about adding more functionality to the search REST API, it looks good. Nice job! Let me know if you need help with the additional functionality. |
Have added the code that @bmenn and I worked on last night. Now we should probably figure out what endpoints would make the most sense and what other information specifically we're looking for from the API. For example, here's a route that gets post titles based on post id:
I think we discussed adding an endpoint with a free text search parameter for words in the title of a post. Were there any others in particular that come to mind? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
Can the CREATE
, *.pyc
, and .DS_Store
files be removed? Maybe those should be added to the `.gitignore.
Another design consideration to think about. Do we want to add pagination to the endpoints that could return a lot of ouput? E.g api/backpage/phone/
could return a lot of data. Perhaps instead of
{
data: [
{
id: <id>,
number: "<number>"
},
...
all the data
]
}
Maybe we should have something like api/backpage/phone/offset=i
{
data: [
{
id: <id>,
number: "<number>"
},
...
i through i + n
]
length: n
}
I don't know a lot about flask or this particular implementation, so let me know if I'm way off. Just a thought
output = str(e) | ||
is_database_working = False | ||
|
||
print (output) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? or just a debug statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add the CREATE
, .pyc
and .DS_Store
files to the gitignore on the next commit.
The lines you mentioned and the entire healthcheck method can be deleted, I just added them to make sure the database was working properly on my machine (for clarity, all this code can be removed):
health = HealthCheck(app, "/healthcheck")
def health_database_status():
is_database_working = True
output = 'database is ok'
try:
session = db.session()
session.execute('SELECT * from backpageemail')
except Exception as e:
output = str(e)
is_database_working = False
print (output)
I'm not a Flask wizard either so I'll look into the pagination and try to implement that if that's possible in Flask. Currently you can pass a specific number or id as a parameter to get a subset of results.
Most of the queries I can remember are there. There should probably be a endpoint for the |
I'll take look at the changes this weekend. Busy week at work. I think you might be able to do pagination with combination of SQLAlchemy and Flask. Examples:
That last link is an amazing resource on Flask. |
Creating this in place of #15 so more people can easily contribute.