php - iOS Post to Python Script on Google App Engine -
So ... the short story is that I was using all of this Apache webserver locally (PHP Using backend) then I wanted to run it on a real web server and thought that Google App Engine would be good for me, it was working for most part (local GAE app with Cloud SQL), but no connection to Google Cloud Storage could get. It seemed that there was not much help in PHP and community () I decided that I would try and switch to Python and give it a shot.
I am still very new to Python, HT, Request, PHP, etc; Please kindly please;) but I can not even get a basic dragon script to work with the iOS application. I'm getting an HTTP Error 404. (Php version worked)
All the codes here are:
Objective-C:
... Post with Username and Password. NSString * post = [[NSString alloc] initWithFormat: @ "email =% @ and password =% @", [auto] User-textfield text], [self Password typefile text]]; NSURL * url = [NSURL URLWithString: @ "http: // localhost: 9080 / login.py"]; // Encoded Post Data NSData * PostData = [Post Data Usage Encoding: NSAPIitit Encoding Permission: Lossy Conversion: Yes]; // Get the length of the post NSString * postLength = [NSString stringWithFormat: @ "% lu", (unsigned long) [postdata length]]; // Format url request with postdata and url NSMutableURLRequest * request = [[NSMutableURLRequest alloc] init]; [Request URL: url]; [Set http system: @ "post"]; [Set set property: post length for http header field: @ "content-length"]; [Request Set Value: @ "App / JSN" HTTP Headerfield: @ "Acceptor"]; [Request Set Value: HTTP HeaderField for @ "App / X-www-Form-URLXode": @ "Content-Type"]; [Set http: bb: postdata]; // [NSURRequestSetNoHTTPSHTTPS certificateCertificate: YesHost: [URL Host]]; NSERR * Error = [[NSIRR Alok] Init]; NSHTTPURL Response * Feedback = Zero; // Send request to see that the username and password are valid NSData * urlData = [NSUR connections send. Synchronous: Response Returning Request: And Feedback Error: & amp; Error];
app.yaml
Application: App2 version: 1 runtime: Python 27 API_version: 1 threadsif: true handler: - url: /.* script : Login .appelication libraries: - Name: webapp2 version: latest
login.py
import webapp2 from webapp2_extras import json class login (webapp2.RequestHandler ): Def post (auto): user_email = self.request.get ('email') # back JSON self.response.content_type = 'application / json' error_message = "email =% s"% user_email obj = {'success' : 0, 'Error_message': error_message,} self.response.write (json.encode (obj)) json.dumps (json.encode (obj)) application = webapp2.WSGIApplication ([('/', log ), Debug = true) Def (): application.run () If __name__ == "__main__": main ()
old login.php
& lt;? PHP header ('content-type: app / jason'); If ($ _ POST) {// Get User Information $ user_email = strip_tags (trim (stroller ($ _ POST ['email']))); Echo json_encode (array ('success' => 0, 'error_message' = & gt; "email = $ user_email")); }? & Gt;
Comments
Post a Comment