Captcha With Google AppEngine - python

I have a website where i want to put a custom made captcha, can't use online captcha services due to layout needs. It runs on google appengine.
Does appengine API has a something for writing characters on a given image?
I went through appengine Python Image API but it doesnot seems to be of much help.
Any suggestions how to generate captcha on google appengine infrastructure?

A quick google search will provide you with plenty of guides for integrating captch services with your AppEngine application. Here's one that uses reCaptcha.

Generally, you can't.
The Image API is designed for transforming existing images, not generating new ones.
Theoretically if you found a pure Python image creation library it would run on App Engine, but it would be slow.
Why not just leverage an external CAPTCHA service?

Instead of creating your own impl. I recommend using a reliable service like reCaptcha:
http://www.google.com/recaptcha

I would suggest using a third-party service like reCaptcha, but in case you really need to provide your own implementation, you could use the recently introduced Matplotlib for GAE+Python to generate your own images.
Matplotlib is a plotting library for Python, and was recently introduced as part of GAE on December of 2012. You can use Matplotlib to render text as shown in this example. If you have aesthetic constraints on your captcha, you can render very fancy text and numbers with Matplotlib. Look at this example.

You can use following code to create Captcha, Please note you have to add commons-lang-2.5.jar in your classpath.
String secutiryCode = RandomStringUtils.random(5, new char[]{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9'});
req.getSession().setAttribute("secutiryCode", secutiryCode);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
URL url = new URL("http://util.krispot.com/util/SecurityImage.jpg?secutiryCode=" + secutiryCode);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
BufferedInputStream bis = new BufferedInputStream(connection.getInputStream());
for(int i = bis.read(); i > -1;i = bis.read()) {
baos.write(i);
}
BufferedOutputStream bos = new BufferedOutputStream(resp.getOutputStream());
bos.write(baos.toByteArray());
bos.close();
Thank you,
Navdeep Singh

Related

Is there any way to share images between two streamlit webapps?

I want to link 2 web pages made using streamlit and hosted using Heroku. One of them removes the image background and the other does an image classification task. (They could not be made into one due to slug size limits of Heroku). At present, the user has to manually download the segmented image from one webpage and upload it to the second webpage.
The 2 can be shown together using an HTML iframe tag but I am not able to figure out how to transfer the segmented image from one webpage to other.
Any suggestion or help will be appreciated
Also please prefer solutions using python and its frameworks as the whole project is in python and learning javascript, HTTP, etc will take some time.
(but if it's not possible using python, answers using other methods will also be welcome)
One of my seniors advised me to explore other hosting options. (I had seen an online tutorial using Heroku , and did not know much about others). It turns out that streamlit cloud provides a much larger slug size and allows you to host it for free if you open source your project(I had no issue doing so), so I have combined the two parts and am now hosting using streamlit cloud.

search google images by image from file in python

I am trying to rename the images in my massive pictures folder by searching google images by each image and naming them the result next to "Best guess for this image: ". I understand that google does have a python API but I am unsure if it can be used in this way, or if that is a reasonable project for someone of my limited experience.
https://developers.google.com/appengine/docs/python/images/usingimages#Uploading seems to be helpful but I'm not sure I understand what I need to be doing conceptually.
Another option is to use the drag-and-drop feature but I have not looked into that as much.
Thanks in advance for any guidance.
As far as I know, Google still doesn't offer a public API for its reverse image search service (i.e. you send a picture and get textual search results).
The most popular alternative that I know is TinEye ( http://www.tineye.com/ ). Here's a link to their RESTful API: http://services.tineye.com/TinEyeAPI

Server-side COLLADA converter

I'm building a web form to accommodate users uploading .obj and .fbx 3D models to a site. We need a server-side solution to convert these files to Collada (dae).
It would be massively helpful if someone could point me in the right direction as I have no solid ideas yet on a possible solution. I'd like to hear what others think before I go off down one path.
I can only think something along the lines of a python/perl script triggered off by the PHP during upload?
Many thanks in advance,
I would use a Python prograam on the server triggered by PHP. I would look around for a Python library for working with Collada files (e.g. http://collada.in4lines.com/) then I would use the FBX Python SDK to convert FBX files to Collada. For OBJ maybe something like http://pygame.org/wiki/OBJFileLoader would be helpful.
Update: I recently wrote a blog post about using FBX and Python as a web server.

How to create an internationalized Google App Engine application

I would like to provide my Python GAE website in the user's own language, using only the tools available directly in App Engine. For that, I would like to use GNU gettext files (.po and .mo files).
Has someone successfully combined Python Google App Engine and gettext files? If so, could you please provide the steps you used?
I had started a discussion in GAE's Google group, but haven't been able to extract from it how I'd like to do it: I don't want to add external dependencies, like Babel (suggested in the discussion). I want to use plain vanilla Google App Engine, so no manual update of Django or this kind of stuff.
At first, I will start using the language sent by the browser, so no need to manually force the language by using cookies etc. However, I might add a language changing feature later, once the basic internationalization works.
As a background note to give you more details about what I'm trying to do, I would like to internationalize Issue Tracker Tracker, an open source application I've hosted on Launchpad. I plan to use Launchpad's translation platform (explaining why I'd like to use .mo files). You can have a look at the source code in it's Bazaar branch (sorry no link due to stackoverflow spam prevention limit for new users...)
Thanks for helping me advance on this project!
As my needs were simple, I used a simple hack instead of (unavailable) gettext. I created a file with string translations, translate.py. Approximately like this:
en={}
ru={}
en['default_site_title']=u"Site title in English"
ru['default_site_title']=u"Название сайта по-русски"
Then in the main code I defined a function which returns a dictionary with translations into the most suitable language from the list (the first one to have a translation is used or English):
import translate
def get_messages(languages=[]):
msgs=translate.en
for lang in languages:
if hasattr(translate,lang):
msgs=getattr(translate,lang)
break
return msgs
Usage:
msgs = get_messages(["it","ru","en"])
hi = msgs['hello_message'] % 'yourname'
I also defined a helper function which extracts a list of languages from Accept-Language header.
It's not the most flexible solution, but it doesn't have any external dependencies and works for me (in a toy project). I think translate.py may be generated automatically from gettext files.
In case you want to see more, my actual source is here.
You can use the Django internationalisation tool, like explained here.
They are also saying that there is no easy way to do this.
I hope that helps you :)

Charts in django Web Applications

I want to Embed a chart in a Web Application developed using django.
I have come across Google charts API, ReportLab, PyChart, MatPlotLib and ChartDirector
I want to do it in the server side rather than send the AJAX request to Google chart APIs, as I also want to embed the chart into the PDF.
Which is the best option to use, and what are the relative merits and demerits of one over the other.
Another choice is CairoPlot.
We picked matplotlib over the others for some serious graphing inside one of our django apps, primarily because it was the only one that gave us exactly the kind of control we needed.
Performance generating PNG's was fine for us but... it was a highly specialized app with less than 10 logins a day.
Well, I'm involved in an open source project, Djime, that uses OpenFlashChart 2.
As you can see from our code, generating the JSON-data that OFC uses is a bit complex, but the output is very nice and user friendly, since you can add tooltips, etc. to the different elements.
Open Flash Chart 2
http://teethgrinder.co.uk/open-flash-chart-2/
python library http://btbytes.github.com/pyofc2/
kybi
One package I've wanted to try is graphite. It's a graphing server / platform built with Django. It's specialized for "numeric time-series data" though, like stock prices or bandwidth utilization. If that fits your need I would check it out. Here are some screenshots:
http://graphite.wikidot.com/screen-shots
I like client side charts because you can get full page plotting.
A good options seems to be Jquery Flot : http://code.google.com/p/flot/ which can load JSON data.
However, you won't get pdf support.
Perhaps you might want to have a look here: Django Plotting app.
The HowTo describes how to embed matplotlib plots into the admin interface and create a PDF view.
I have used FusionCharts Free with Django.
Its flash based, open source, multi-licensed and it's well documented. It's ActionScript 1, but AS version wasn't really a criteria for me, though it could be for others.

Categories

Resources