Showing posts with label server. Show all posts
Showing posts with label server. Show all posts

Friday, May 13, 2011

How to Access a Cassini (IIS in Visual Studio) hosted site from a remote machine

Visual Studio provides Cassini (a local only version of IIS for Web Projects in Visual Studio) for developers to test their projects on their systems without having to use the real IIS server. However, it also imposes a restriction that only the localmachine (OS on which Visual Studio is Installed) can access it. Following the steps here would allow us to go around this restriction and view a site hosted on the Cassini server from another host (machine or virtual-machine) which is on the network. This helps when doing cross-platform or cross-browser UI testing.

 

Perquisites:

  1. Remote Machine/VM.
  2. Fiddler 2 (download from here). TIP: We will use its reverse proxy capabilities.

Steps:

  1. If using a VM, make sure you are using the Shared Networking/Bridged Mode.
  2. Build and Run the web-application/web-project on Visual Studio and make sure you can access it on your local machine. Take note of the port on which is hosted.
  3. Start fiddler and open from the menu. Tools > Fiddler Options.
  4. Go to the ‘Connections’ Tab and make sure the option - “Allow remote computers to connect” - is check marked.
  5. Customize the “Fiddler listens on port:” to a port not used by any application on your system (e.g. 9999)
  6. Click [Ok] button to save these options.
  7. Press ‘Ctrl+R’ to Customize rules (You can also go to Rules > Customize rules). This generally opens the rules file in notepad (or the default editor)
  8. Find the function OnBeforeRequest (The rule files follows the Jscript syntax)
  9. At the end of this function add these line:
    if (oSession.host.toLowerCase() == "192.168.2.6:9999"){ oSession.host = "localhost:58060"; } // The IP address is the original machine's (with Cassini) IP // the localhost:port is the application port on Cassini
  10. Run cmd.exe and renew your IP by doing an:
    >> ipconfig /release followed by  >>ipconfig /renew
  11. From your browser in remote machine/VM access IP:<Fiddlers port>. e.g.
    http://192.168.2.6:9999 

You should be seeing the website, served from Cassini, on the remote machine!

Posted via email from Abhishek Dev

Tuesday, February 15, 2011

Using MySQL with Python/Django on Mac OS X (Snow Leopard)

Setting up MySQL with Python ( or Django ) can be a bit tricky since no database driver is officially provided by MySQL (as of Feb 2011). I had a couple of failed attempts, but finally got it working. A hit and trial method and troubleshooting guides from various websites helped. To sum it up, here is what worked for me:

Environment:

  1. Mac OS X 10.6.6
  2. Python 2.6.1 (Django supports this version and is installed on Mac by default if Xcode is installed)
  3. GCC 4.2.1
  4. MySQLdb 1.2.3 (Download from http://sourceforge.net/projects/mysql-python/)
  5. MySQL 5.1.x Server (Since MySQLdb supports upto this version as of Feb 2011)

Don't try to reuse the MySQL installed as part of MAMP because it doest match typical deployment environments if you would use Python/Django for professional application and secondly its overtly complicated.

Install MySQL:

See previous post Install/Uninstall MySQL 5.1 on Mac @ http://abhishekdev.posterous.com/installuninstall-mysql-51-on-mac

Perquisites: before installing MySQLdb

  1. Add the following line to the ~/.bash_profile or ~/.profile (Found by default on10.6.x) file under the User Home (if ~ is not known to you)
    PATH="${PATH}:/usr/local/mysql/bin" 
  2. Type in Terminal
    mysql --version
    Should read something similar to "mysql  Ver 14.14 Distrib 5.1.55, for apple-darwin10.3.0 (i386) using readline 5.1"

Install MySQLdb:

  1. Extract MySQLdb if it came archived/compressed
  2. Open Terminal
  3. Make the extracted folder as current working directory
    cd [Path if any]MySQL-python-1.2.3
  4. Type in Terminal
    python setup.py build sudo python setup.py install
  5. If no Errors get thrown. In Python Prompt type "import MySQLdb"
    python import MySQLdb

Posted via email from Abhishek Dev