Posts marked with "WWW" in tags

Program to Replace localhost links with website url

If you are working on a project and wants to upload the project to your site, then you have to manually replace all the localhost links with the site url. I created a small Python program that will replace localhost links with your WWW site url.
Here is the Python code :

#!/usr/bin/python
import os
indir = ‘/var/www/mysite‘ #!Folder of your localhost site.
for root, dirs, filenames in os.walk(indir):
 for f in filenames:
  log = open(os.path.join(root, f), ‘r+’)
  f=log.read()  
  n=f.replace("http://localhost", "http://mysite.com")
  log.seek(0)
  log.truncate()
  log.write(n)
  log.close()
print "Successfully Replaced."

... [READ MORE]

Follow/Subscribe

Telegram 

Mastodon  Twitter

GitHub GitLab

Subdomains

Demos  Lab

Past

This blog was once on WordPress. Now a static site. See source code on

GitLab