質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Flask

FlaskはPython用のマイクロフレームワークであり、Werkzeug・Jinja 2・good intentionsをベースにしています。

SQLAlchemy

SQLAlchemyとはPython 用のORMライブラリです。MIT Licenceのオープンソースとして提供されています。

.htaccess

Apacheウェブサーバーにおいて、ディレクトリ単位で設置及び設定を行う設定ファイルを指します。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

HTML

HTMLとは、ウェブ上の文書を記述・作成するためのマークアップ言語のことです。文章の中に記述することで、文書の論理構造などを設定することができます。ハイパーリンクを設定できるハイパーテキストであり、画像・リスト・表などのデータファイルをリンクする情報に結びつけて情報を整理します。現在あるネットワーク上のほとんどのウェブページはHTMLで作成されています。

Q&A

解決済

2回答

1276閲覧

Lilipopでpythonを動かす際のエラー

kou-pen

総合スコア11

Flask

FlaskはPython用のマイクロフレームワークであり、Werkzeug・Jinja 2・good intentionsをベースにしています。

SQLAlchemy

SQLAlchemyとはPython 用のORMライブラリです。MIT Licenceのオープンソースとして提供されています。

.htaccess

Apacheウェブサーバーにおいて、ディレクトリ単位で設置及び設定を行う設定ファイルを指します。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

HTML

HTMLとは、ウェブ上の文書を記述・作成するためのマークアップ言語のことです。文章の中に記述することで、文書の論理構造などを設定することができます。ハイパーリンクを設定できるハイパーテキストであり、画像・リスト・表などのデータファイルをリンクする情報に結びつけて情報を整理します。現在あるネットワーク上のほとんどのウェブページはHTMLで作成されています。

0グッド

0クリップ

投稿2021/08/22 13:31

Python,Flaskを用いたプログラム

上記の通り、Lolipopでブログのようなプログラムを動かしたいのですが、
Internal Server Errorが出てしまいます。
最小限のコードでは動きましたが、オリジナルの物をアップロードするとエラーになってしまいます
解決策を提示していただけると幸いです。

エラーメッセージ

Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at https://lolipop.jp/support/ to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

該当のソースコード(すべて貼っておきます)

python

1#views.py 2from typing import Text 3from flask import Flask,request,redirect,url_for,render_template,flash,session 4from sqlalchemy.sql.functions import user 5from models.entries import Entry ,SESSION,User 6from sqlalchemy.engine import base 7from sqlalchemy import text 8from datetime import datetime 9 10app = Flask(__name__) 11app.config['DEBUG'] = True 12app.config['USERNAME'] = 'admin' 13app.config['PASSWORD'] = 'admin' 14app.config['SECRET_KEY'] = 'gmowyu7938q2y7uhfsiu7827rngw7390167reidnsdhgoi2yifg6t783hj4i' 15 16@app.route('/') 17def show_entries(): 18 if not session.get('logged_in'): 19 return redirect(url_for('login')) 20 entrie = SESSION.query(Entry).all() 21 usernames = session.get('username') 22 return render_template('home.html',entries = entrie,usernames = usernames) 23@app.route('/signup', methods=['GET', 'POST']) 24def signup(): 25 if request.method == 'POST': 26 userm = User( 27 name = request.form['usernames'], 28 password = request.form['passwords'], 29 ) 30 SESSION.add(userm) 31 SESSION.commit() 32 flash('signuped') 33 return redirect(url_for('login')) 34 elif request.method == 'GET': 35 return render_template('signups.html') 36 else: 37 pass 38@app.route('/login',methods=['GET','POST']) 39def login(): 40 if request.method == 'POST': 41 pname = request.form['username'] 42 p1 = SESSION.query(User).filter(text("name=:name")).params(name=pname)#.first() 43 44 for row in p1: 45 NAME = row.name 46 PASSWD = row.password 47 if request.form['username'] != NAME: 48 flash('error:username') 49 elif request.form['password'] != PASSWD: 50 flash('error:passwd') 51 else: 52 session['logged_in']=True 53 session['username']=NAME 54 flash('logged_in') 55 return redirect(url_for('show_entries')) 56 return render_template('login.html') 57@app.route('/logout') 58def logout(): 59 session.pop('logged_in',None) 60 session.pop('username',None) 61 flash('logged out') 62 return redirect(url_for('show_entries')) 63@app.route('/entries',methods=['POST']) 64def add_entry(): 65 if not session.get('logged_in'): 66 return redirect(url_for('login')) 67 entry = Entry( 68 long = request.form['long'], 69 subject = request.form['subject'], 70 comment = request.form['comment'], 71 created_at = datetime.utcnow() 72 ) 73 SESSION.add(entry) 74 SESSION.commit() 75 flash('created') 76 return redirect(url_for('show_entries')) 77@app.route('/entries/new') 78def new_entry(): 79 if not session.get('logged_in'): 80 return redirect(url_for('login')) 81 return render_template('new.html')

python

1#entries.py 2from sqlalchemy.sql.sqltypes import DateTime, Time 3from sqlalchemy import create_engine 4from sqlalchemy.ext.declarative import declarative_base 5from sqlalchemy import Column, Integer, String 6from sqlalchemy.orm import sessionmaker 7 8engine = create_engine('sqlite:///coco.db', echo=True , connect_args={'check_same_thread': False}) #, timeout=10, uri=True , check_same_thread=True 9Base = declarative_base() 10class Entry(Base): 11 __tablename__ = 'entries' 12 id = Column(Integer,primary_key=True) 13 long = Column(String(10)) 14 subject = Column(String(50)) 15 comment = Column(String(50)) 16 created_at = Column(DateTime) 17 class User(Base): 18 __tablename__ = 'user' 19 id = Column(Integer, primary_key=True) 20 name = Column(String) 21 password = Column(String) 22 roll = Column(String) 23 Session = sessionmaker(bind=engine) 24SESSION = Session() 25Base.metadata.create_all(engine) 26userdata = User( 27 name = "admin", 28 password = "admin", 29 roll = True 30) 31SESSION.add(userdata) 32SESSION.commit()

python

1#config.py 2DEBUG=True 3USERNAME='admin' 4PASSWORD='admin' 5SECRET_KEY = 'f47wyhdfa8387hadfja3798293uhda83jk' 6SQLALCHEMY_DATABASE_URI = 'sqlite:///coco.db' 7SQLALCHEMY_TRACK_MODIFICATIONS = True

python

1#!/usr/local/bin/python3.7 2#index.cgi 3from wsgiref.handlers import CGIHandler 4from views import app 5CGIHandler().run(app)
#.htaccess RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ /ffftp/index.cgi/$1 [QSA,L]

html

1<!--home.html--> 2{% extends "layout.html" %} 3{% block content %} 4<ul class="list-group list-group-flush"> 5 {% for entry in entries %} 6 <div class="card"> 7 <div class="card-body"> 8 <h5 class="card-title">{{ entry.id }}:{{ usernames }}さんが、{{ entry.subject }}を{{ entry.long }}分学習しました!</h5><!--{{ usernames }}さんが、--> 9 <h6>一言:{{ entry.comment }}</h6> 10 <h7>created-at:{{ entry.created_at }}</h7> 11 </div> 12 </div> 13 {% else %} 14 noarticle 15 {% endfor %} 16</ul> 17{% endblock %}

html

1<!--layout.html--> 2<!DOCTYPE html> 3<title>coco study</title> 4<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"> 5<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script> 6<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script> 7<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script> 8<div class="container"> 9 <nav class="navbar navbar-expand-lg navbar-light bg-light"> 10 <a class="navbar-brand" href="{{url_for('show_entries')}}">Coco study</a> 11 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> 12 <span class="navbar-toggler-icon"></span> 13 </button> 14 <div class="collapse navbar-collapse" id="navbarNav"> 15 <ul class="nav navbar-nav navbar-right"> 16 {% if not session.logged_in %} 17 <li class="nav-item"> 18 <a class="nav-link" href="{{url_for('login')}}">login</a> 19 </li> 20 <li class="nav-item"> 21 <a class="nav-link" href="{{url_for('signup')}}">signup</a> 22 </li> 23 {% else %} 24 <li class="nav-item"> 25 <a class="nav-link" href="{{url_for('new_entry')}}">new entry</a> 26 </li> 27 <li class="nav-item"> 28 <a class="nav-link" href="{{url_for('logout')}}">logout</a> 29 </li> 30 {% endif %} 31 </ul> 32 </div> 33 </nav> 34 {% for message in get_flashed_messages() %} 35 <div class="alert alert-info" role="alert"> 36 {{ message }} 37 </div> 38 {% endfor %} 39 <div class="blog-body"> 40 {% block content %} 41 {% endblock %} 42 </div> 43</div>

html

1<!--login.html--> 2{% extends "layout.html" %} 3{% block content %} 4<form action="/login" method="POST"> 5 <div class="form-group"> 6 <label for="InputTitle">username</label> 7 <input type="text" class="form-control" id="InputTitle" name="username"> 8 </div> 9 <div class="form-group"> 10 <label for="InputPassword">password</label> 11 <input type="password" class="form-control" id="InputPassword" name="password"> 12 </div> 13 <button type="submit" class="btn btn-primary">login</button> 14</form> 15{% endblock %}

html

1<!--new.html--> 2{% extends "layout.html" %} 3{% block content %} 4<form action="{{url_for('add_entry')}}" method="POST" class="add-entry"> 5 <div class="form-group"> 6 <label for="InputSubject">Subject</label> 7 <input type="text" class="form-control" id="InputSubject" name="subject"> 8 </div> 9 <div class="form-group"> 10 <label for="Inputlong">long</label> 11 <input type="text" class="form-control" id="Inputlong" name="long"> 12 <label for="Inputlong"></label> 13 </div> 14 <div class="form-group"> 15 <label for="inputcomment">comment</label> 16 <input type="text" class="form-control" id="Inputcomment" name="comment"> 17 </div> 18 <button type="submit" class="btn btn-primary">create</button> 19</form> 20{% endblock %}

html

1<!--signups.html--> 2{% extends "layout.html" %} 3{% block content %} 4<form action="/signup" method="POST"> 5 <div class="form-group"> 6 <label for="Inputname">username</label> 7 <input type="text" class="form-control" id="Inputname" name="usernames"> 8 </div> 9 <div class="form-group"> 10 <label for="InputPassword">password</label> 11 <input type="password" class="form-control" id="InputPassword" name="passwords"> 12 </div> 13 <button type="submit" class="btn btn-primary">signup</button> 14</form> 15{% endblock %}

試したこと

lolipopのパス、パーミッション、htaccess、index.cgiの修正

補足情報

ディレクトリ構造

/| |-/models |-__init__.py(空) |-entries.py |-/templates |-home.html |-layout.html |-login.html |-new.html |-signups.html |-.htaccess |-__init__.py(空) |-coco.db |-config.py |-index.cgi |-views.py

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

自己解決

サーバーごと変えました

投稿2021/10/26 11:03

kou-pen

総合スコア11

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

plain

1Internal Server Error 2The server encountered an internal error or misconfiguration and was unable to complete your request. 3Please contact the server administrator at https://lolipop.jp/support/ to inform them of the time this error occurred, and the actions you performed just before this error.

GoogleTranslation

1Google翻訳 2 3内部サーバーエラー 4サーバーで内部エラーまたは構成ミスが発生し、リクエストを完了できませんでした。 5このエラーが発生した時刻と、このエラーの直前に実行したアクションについては、サーバー管理者(https://lolipop.jp/support/)に連絡してください。

というエラーメッセージが出ているのですから、それに従いましょう。

投稿2021/08/22 23:07

ppaul

総合スコア24666

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

kou-pen

2021/08/25 23:54

LolipopのサポートにCGIの中身については対象外と言われてしまったので、自力でやっていこうと思います
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問