jonilyn2730
jonilyn2730

Reputation: 475

MobileApp Architecture: Allow process client request using server scripts

I am working on capstone project and I am looking for ideas to implement this one.

I have a working web application that was created using OpenCV Python and deployed on a Django Framework. Now I want to also create a hybrid mobile application for the project. The idea is, the mobile app will allow the user to upload an image to the server, and then the web server will process the image then finally return a response to the mobile app.

===============================

Client (Hybrid Mobile app):

  1. Take image

Web server:

  1. Receive user uploaded image
  2. Call Image Processing class (views.py) and do something more in the backend
  3. Save the result to the database
  4. Display the result to the client/Response to client (could be a page redirect)

============================

I know that it is possible to save an image to the database through REST API, however, I have no idea if it is possible for the client side to call a class from the server side through REST API? If no, then is there any other way to implement this method? Do know any references that can give me some ideas on how to implement it?

Upvotes: 0

Views: 33

Answers (1)

Kritz
Kritz

Reputation: 7321

You can't call a class on the server from the mobile phone.

You can just post the file to your view (this will differ based on what architecture the app is running):

files = {'file': ('file_name.jpeg', file_data)}
response = requests.post(url, files=files, auth=(USERNAME, PASSWORD))
# add error checking etc

It sounds like you need to read up a bit more about creating an API. Most commomly, when you want data you do a http get and the data is returned in json. When sending data you do a http post.

Also, don't save file data directly in the database

Upvotes: 0

Related Questions