Giter Site home page Giter Site logo

post-image-example's Introduction

post-image-example

Small example showing how to post image from Android app and recieve the data on a Flask server.

About

This app is a simple prototype for sending an image via POST request from an Android app to a Flask server. Upon opening the app, it will automatically post the image you specify in the MainActivity.java file. It will also send some text over to the Flask server. Upon reciveing your post, the Flask server will (1) save the image file you post to the local machine and (2) return any text data you sent back to the Android app. The Android app simply shows any returned data, in raw JSON, as a Toast.

Usage

To run this, you will need the HTTP Components libraries. Download these here: https://hc.apache.org/downloads.cgi. I tested this using version 5 beta 2. Simply download the zip file and place all the jars into your Android Studio project (in the app->libs directory).

The file svr.py in the root of the project is the Flask server. It is configured to expose the API to any device on your home network. You will need to install Flask (via pip) to make this work. I used a virtualenv, so that should work fine.

In MainActivitiy.java, make note of the Todos. You will want to edit the IP address to be the IP of the computer you are running the Flask server on. The file path can be any file on your phone. It should support either PNG or JPEG images, but if you use anything that's not a PNG, you will have to edit the svr.py file to write your data out as that file type.

post-image-example's People

Contributors

adamhs1997 avatar

Stargazers

qidiso avatar

Watchers

James Cloos avatar

Forkers

qidiso

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.