前提
Pythonをcgiとして動かそうとしています。
他の.pyは意図通りに現在動いています。
実現したいこと
500 Internal Server Error を解消したいです。
何か基本的な事を見落としていると思うのですが、原因を特定できていません。
サーバーに上げている問題のURLは、
https://appli.mac-in.net/youtube-support_registration_square/accessDB_test002.py
パーミッションは755にしてあります。
例として問題なく動いているURL、
https://appli.mac-in.net/youtube-support_registration_square/custom_url_YSC.py
該当のソースコード
Python
1#!/usr/local/bin/python3 2# coding:utf-8 3 4#import os 5#import sys 6import cgi 7#from ast import keyword 8#import re 9#sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), '../../../vendor')) 10#import requests 11 12print('Content-type: text/html') 13print('Status: 200 OK')
htaccess
1ErrorDocument 404 /index.html 2DirectoryIndex index.html index.php index.cgi 3 4Options +Includes 5AddHandler php7.4-script .php .html 6AddHandler cgi-script .py 7AddHandler server-parsed html
試したこと
元々はもう少し長いコードなのですが、500 Internal Server Errorの原因を特定するために、最小限のコードまで絞りました。
それが上記のソースコードです。
webブラウザも疑って、Firefox、Safariとやってみました。キャッシュのクリアも試しました。
補足情報(FW/ツールのバージョンなど)
サーバー:ロリポップ
端末:macOS Mojave 10.14.6
上記、意図通りに動いている例のcustom_url_YSC.pyのソースコード
Python
1#!/usr/local/bin/python3 2# coding:utf-8 3 4import os 5import sys 6import cgi 7from ast import keyword 8import re 9sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), '../../../vendor')) 10import requests 11from bs4 import BeautifulSoup 12 13print('Content-type: text/html\n') 14print('Status: 200 OK') 15#print(os.path.join(os.path.abspath(os.path.dirname(__file__)))) 16 17channelID_len = 24 #チャンネルIDの長さ 18keyWord = '"browseId":"' 19url = sys.stdin.readline() #JavaScriptから受け取る 20#url = 'https://www.youtube.com/c/TsuriHamTVAnother%E9%87%A3%E3%82%8A%E3%83%8F%E3%83%A0TVA' 21# seikai = 'UC_zCH7-RTmaFEvSWoE6z5QA' 22 23res = requests.get(url) 24soup = BeautifulSoup(res.text, "html.parser") 25mojiretsu = str(soup) 26keyPosition = mojiretsu.find(keyWord) 27channelID = mojiretsu[keyPosition + len(keyWord) : keyPosition + len(keyWord) + channelID_len] 28 29print('data:' + channelID) #JavaScriptに渡す

回答1件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
また依頼した内容が修正された場合は、修正依頼を取り消すようにしましょう。