Python CGI file created on Windows

Note that it took a lot of time to move the Python CGI file I was trying in the local environment of Windows to Mac OS X. Assuming a CGI file called upload.py under the cgi-bin folder.

Reference URL: http://d.hatena.ne.jp/yoshiya_na/20110521/1305978743

(1) Check / change the permissions of CGI files

cd cgi-bin
ls -lF
chmod 755 upload.py #Can be executed by all users, but cannot be written by anyone other than the owner

(2) Check the line feed code Unix, Mac OS X: LF Mac OS (up to version 9): CR Windows: CR-LF To match.

nkf -Lu --overwrite upload.py

Overwrite the original file and set the line feed code to LF.

Or, if you think about removing CR from a file created on Windows (reference: http://stackoverflow.com/questions/19425857/env-python-r-no-such-file-or-directory)

with open('upload.py', 'rb+') as f:
    content = f.read()
    f.seek(0)
    f.write(content.replace(b'\r', b''))
    f.truncate()

Recommended Posts

Python CGI file created on Windows
Python on Windows
python basic on windows ②
Set-enable Python virtualenv on Windows
Run Openpose on Python (Windows)
Install watchdog on Windows + Python 3.3
Python + Kivy development on Windows
Sphinx-autobuild (0.5.2) on Windows7, Python 3.5.1, Sphinx 1.3.5
Fastest Python installation on Windows
Build Python environment on Windows
Run Python CGI on CORESERVER
Build python environment on windows
I ran python on windows
[Python] [Chainer] [Windows] Install Chainer on Windows
Use Python on Windows (PyCharm)
Python environment construction memo on Windows 10
Python 3.6 on Windows ... and to Xamarin.
Installing Kivy on Windows10 64bit Python3.5
Tips on Python file input / output
Anaconda python environment construction on Windows 10
Install python2.7 on windows 32bit environment
Install xgboost (python version) on Windows
Install Python on Windows + pip + virtualenv
Install Pytorch on Blender 2.90 python on Windows
Integrate Modelica and Python on Windows
Installing Kivy-Designer on Windows10 64bit Python3.5
Mecab / Cabocha / KNP on Python + Windows
Install Python development environment on Windows 10
Getting started with Python 3.8 on Windows
Reproduce One-Touch Search on Python 3.7.3. (Windows 10)
Japanese file enumeration with Python2 system on Windows (5C problem countermeasure)
Notes for using OpenCV on Windows10 Python 3.8.3.
Run servo with Python on ESP32 (Windows)
Python 2.7, 3.4, 3.5 extension module build environment on Windows
[Kivy] How to install Kivy on Windows [Python]
Build CGI Server running on Python 3 on Docker
Virtualenv does not work on Python3.5 (Windows)
Creating a python virtual environment on Windows
Created Ubuntu, Python, OpenCV environment on Docker
Use without installing python 2.x on Windows
Script python file
twitter on python3
Python installation (Windows)
Python file processing
python on mac
Python on Windbg
Project cannot be created with Python3.5 (Windows) + django1.7.1
Install and run Python3.5 + NumPy + SciPy on Windows 10
Put MicroPython on Windows to run ESP32 on Python
Install Python3, numpy, pandas, matplotlib, etc. on Windows
Open a ZIP created on Windows in Linux
Simply build a Python 3 execution environment on Windows
Notes on installing Python3 and using pip on Windows7
Develop Windows apps with Python 3 + Tkinter (exe file)
GUI (WxPython) executable file (pyInstaller) [Windows] in Python3
The .pyd file is the DLL itself on Windows
[Python] How to install OpenCV on Anaconda [Windows]
[Note] Installing Python 3.6 + α on Windows and RHEL
Installing TensorFlow on Windows Easy for Python beginners
Create a Python virtual development environment on Windows
Install ZIP version Python and pip on Windows 10