Running python on apache with a samba share. permissions

I got Apache to run python scripts but the problem is that it only runs scrips that i create in the terminal. I have the directory where the python files are shared with samba and would like to edit them on a windows machine.
Here is apaches eror log that i get.
[Fri Apr 28 16:19:13.054804 2017] [cgi:error] [pid 28530] [client] AH01215: (13)Permission denied: exec of '/var/www/html/cron/cgi-bin/' failed
[Fri Apr 28 16:19:13.055812 2017] [cgi:error] [pid 28530] [client] End of script output before headers:

Also when i try to open the file that i made in terminal and works. It is empty.

The problem is in Line ending characters and its fixebol. The fact that i need to chmod every new file is the bad side. Is there a way i could fix that.

Maybe try setting the ownership of the files with chown:

    sudo chown -R apache:apache /var/www/html
The -R is the recursive flag telling chown to change the file permissions for every file in the directory in /var/www/html and any folders it may contain.

Thank you.
It helps but still has the problem of new files being created , i could tell crontab to run the command every 10 mins or so but that seems impractical is there a better way?

I think you will have to edit the samba config to force any new file to be attributed to a specific user and to force a permission scheme so that your samba user will be able to edit the files. I can share my samba config later in the day.

Edit: So here is an example.

[Apache Python Scripts]
path = /var/www/html
browseable = yes
writable = yes
guest ok = yes
read only = no
create mask = 0770
directory mask = 0770
force user = apache
force group = apache

Alternatively you can change the masks, for example 0777 for debugging, then begin retracting certain permissions, like making it 0770 for instance, and see if it still works. Also, if you have an smb user you log in with, which is tied to a user on the system, you can have than user join the group apache (and so 0770 should work), or alternatively, make the apache user join the smb users group. I don't know which way is better.

Edit: for clarity, this config will let anyone (guest) open the smb share. Anything that gets written to the share is owned by apache and belongs to the group apache. It has the permissions 770, which means the owner and the owners group can read/write/execute the files, and 0 at the end means no-one else can do anything. 777, with a 7 in the end means anyone in the whole wide world can do anything to the files.

try chmod -R g+w /var/www/html
or which ever folder is in play.
smb can be real stubborn at times, g+w should allow for the group to use/write the files as well.
problem is if you write a new file to a folder which is shared, it belongs to you, and the group, but since it is your file, the other members of the group cannot touch the file.
normally when i do a smb share i use chown -R me:group, chmod -R 775 /Folder/in/question, chmod -R g+w /Folder/in/question.

I think they can if their primary group is the same one (and the permission scheme allows for group editing, for instance 7), i.e if you make it the first group appearing when you check group membership with $ groups <username> . If it is simply a matter of an smb user who's only lot in life is to plot text files into a folder, it will not have any other ramifications. But your method might be easier and work better in the end, for instance if he/she does not log in to the share with a system user.