my net house

WAHEGURU….!

Flask for vitualenc

Today something happened it can be considered as bug also.
In the virtual env when I install flask after activation of virtual environment it goes to the installation successfully but when I try to “import flask” does not come up, May be problem in virtualenv of flsk bug but when I do following things do work.

You may need/not-need to use Sudo according to the Nature of your environment.

$ flask/bin/pip install flask
$ flask/bin/pip install flask-login
$ flask/bin/pip install flask-openid
$ flask/bin/pip install flask-mail
$ flask/bin/pip install flask-sqlalchemy
$ flask/bin/pip install sqlalchemy-migrate
$ flask/bin/pip install flask-whooshalchemy
$ flask/bin/pip install flask-wtf
$ flask/bin/pip install flask-babel
$ flask/bin/pip install guess_language
$ flask/bin/pip install flipflop
$ flask/bin/pip install coverage
OMG after writing too much post I did not even made smiely, here it is. :D :D :D

Instantiation Python classes

Ok I wrote a great article in instanseation Python classes but I guess it is deleted somehow. :( :P

Following was the refrence for Future:
http://www.diveintopython.net/object_oriented_framework/instantiating_classes.html

Docker and it’s promises (Only hello world)

This is quite on the way thing about Docker,

You just become about the Technology that you know you are going to use a lot for rest of your life,

Ok Lets Dock…!!

Running Docker+Django on Production is bit different then running on Development server.

At production we need WSGI, But Why Wsgi.. ? Security?

Well Security is not the only thing, But it makes lot of Sense when using WSGI, Because all the Python things does not come with Development server, They may come But having WSGI with you is far better to Play anything on Apache, Nginx or on whatever, Ok WSGI is fine to have right now..

 

At present I don’t want to make things not complicated for me.

When usingĀ  Docker there are many thing those we need to look after to build our Docker Image, But if there are already available images then we can work on that and have fun to use them for our goodness.

This Guy is awesome: https://registry.hub.docker.com/u/grahamdumpleton/mod-wsgi-docker/

He provides everything you need to know about Docker and WSGI with Django all the time…

So WSGI is just like writing your Python scripts and run those on browser,..

A simple WSGI:file

<code>

def application(environ, start_response):
 status = '200 OK'
 output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
 ('Content-Length', str(len(output)))]
 start_response(status, response_headers)
return [output]

</code>

Create a <strong>new directory</strong> and save above file as wsgi.py in that directory.

Now time for <strong>Dockerization</strong>

Now in the same directory Create Dockerfile. To avoid confusion I mean to say $ nano Dockerfile

yes Dockerfile is a text file.

and add following two line:

<code>

FROM grahamdumpleton/mod-wsgi-docker:python-2.7-onbuild
CMD [ "wsgi.py" ]

</code>

The above lines of code say many things itself, (at least I believe that)

then run following two commands one by one: obviously ;)

<code>

docker build -t my-python-app .
docker run -it --rm -p 8000:80 --name my-running-app my-python-app

</code>

The Hello World WSGI application will now be accessible by pointing your browser at port 8000 on the Docker host.

http://<your-ip&gt;:8000

 

Docker compose Docker 1.6

Ok I deployed Django Project on Server in just 50 seconds and it is as much as secore,robust and as fast as possible as it could be in real life.

There are things we need to discuss first.

Docker 1.6 uses docker-compose to deploy Django Application on the server:

http://docs.docker.com/compose/django/

What is Docker-Compose?

Compose is a tool for defining and running multi-container applications with Docker. With Compose, you define a multi-container application in a single file, then spin your application up in a single command which does everything that needs to be done to get it running.

Ok let’s tune for more. Docker <3 <3

Algorithms are changing the world

Most of the times I got my self to much overwhelmed when I see Awesome-Automation movies, Ok let’s come to the point that Algorithms are changing the world, Yes they are completely:

Now a programmer can define set of instructions which can understand the feelings of any person and according to those feelings program can also act the things:

<Simple version is as follows> :Mostly Pythonic:

def angry:

“what someone do when someone is angry”

def angry_prevention:

“What computer should do when someone is angry”

def happy:

“What someone do when someone is happy”

def happy_prevention:

“Over-happiness could be harmful to someone” (Just a random thought)

<<<<<<<<<<<<So now we have defined two four funcations>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

A system which can detect facial expressions of human is already developed so some if-else statements and we can control a human in two conditions which is happy and sad:

One is left called “Normal condition”——> This needs time because being normal is complex. ;) so as defining to ;)

Python list thing. (INdex out of range)

most of hte time I forget this thing and consumes my time.

if I have a list:

a = [‘435 456 123 334 769’]

print a[0]

will give output same as – > [‘435 456 123 334 769’]

but if i run print a[1] it will return Index Out of range. Obvious thing….

So what I do to solve this

for numbers in a[0].split():

print number

Which gives me exact thing I need. Actually split() function splits all the elements of list in the given index.

Django Database error

Basically if you are on ubuntu or Debian you need to make www-data owner for database and Django directory.

http://fredericiana.com/2014/11/29/sqlite-error-open-database-file/ you can also use -R option.

Equally important

http://serverfault.com/questions/57596/why-do-i-get-sqlite-error-unable-to-open-database-file

Google gmail oauth

Ihave no idea what the rest of the world say:

But following things work for me amazingly

https://localhost

https://localhost:8000/ # Remember ” / ” —> just https://localhost:8000 will give the URI miss-match error

Docker and other important things

One thing I am sure about now is there are toys around me whose I need to learn to play.. <3

REST Python API

Requests module

Docker

Django

WSGI-> well what I know is it is medium between Webserver and your Application.

Application <WSGI> Python-application

Docker… Why?

It is Linux container, You can use containers to development.

Container seems better options to do things rather than normal..

Dear GOD, Please provide me chance to play with it!

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: