is there anyway I can edit a file that I dont have permission for?

Joined
Dec 10, 2010
Messages
1
Reaction score
0
Points
1
Hi, ive been messing around with terminal and I saw this code that can set up a very simple server on your 8080 port

python -m SimpleHTTPServer 8080

And it works great and ive had fun messing around with it, but when i put an html file named index.htm or named anything else, the html code isn't translated into the page, it justs displays the code

i've navigated to the file

/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SimpleHTTPServer.py

and found that when I edit it, i can edit the html file that is the root directory when you start that server, the only thing is that I can't save the file as i dont have permission. Anyone have any tips?
 
Joined
Dec 4, 2010
Messages
6
Reaction score
0
Points
1
Edit the file however you need to. Save it to your desktop. Then copy the saved file to the originals location in Finder. In the dialogs that pop up click Replace, and put in your password.
 
Joined
Apr 9, 2009
Messages
2,073
Reaction score
68
Points
48
Location
Ithaca NY
Your Mac's Specs
13 inch alMacBook 2GHz C2D 4G DDR3, 1.25GHz G4 eMac
or sudo chmod 777 /file/path/here
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Just a tip - you shouldn't be using Python's SimpleHTTPServer for anything serious (I'm not saying you are though).

A much easier solution would be to simply write a small server in Python using SimpleHTTPServer and run that from a directory that you have permissions to. Using Python's docs to help me here (I'm largely unfamiliar with the SImpleHTTPServer module), create a file called <something>.py (replace <something> with whatever you want) and make the contents of the file the following:
Code:
import SimpleHTTPServer
import SocketServer

PORT = 8000

Handler = SimpleHTTPServer.SimpleHTTPRequestHandler

httpd = SocketServer.TCPServer(("", PORT), Handler)

print "serving at port", PORT
httpd.serve_forever()
Execute that by executing
Code:
python <something>.py
Put your html docs in the directory with the Python script and navigate to http://localhost:8000 (change the port if you change it in the script).
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top