Python Forum
500 Internal Server Error Flask Api on Lighttpd
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
500 Internal Server Error Flask Api on Lighttpd
#1
I've struggling for few days to build Flask Api under Lighttpd (under Rasp Pi) but having problem of "500 Internal Server Error".

under "/var/www/api/api.py",
#!/usr/bin/env python
import requests
from flask import Flask
from flask import request
from flask import jsonify

app = Flask(__name__)

@app.route("/", methods=["GET"])
def home():

    #return "<h3>TestLine</h3>"
    return jsonify("TestLine")

@app.route("/GetDevice", methods=["GET"])
def getdevice():

    Subject = request.args.get("Subject")

    return jsonify("TestLine 123")

app.run(host = "0.0.0.0", port = 80)
under "/var/www/api/api.fcgi",
#!/usr/bin/env python
from flup.server.fcgi import WSGIServer
from api import app

if __name__ == "__main__":
    WSGIServer(app, debug = True).run()
under "/etc/lighttpd/lighttpd.conf",
debug.log-request-handling = "enable"

server.modules   += ( "mod_fastcgi" )

server.modules   += ( "mod_rewrite" )

server.modules   += ( "mod_alias" )

server.modules   += ( "mod_accesslog" )

server.document-root        = "/var/www"

#server.port = 80

server.modules += ( "mod_cgi" )

mimetype.assign = (
 ".html" => "text/html", 
 ".txt" => "text/plain",
 ".jpg" => "image/jpeg",
 ".png" => "image/png",
 ".js" => "text/javascript",
 ".css" => "text/css"
)

static-file.exclude-extensions = ( ".fcgi", ".php", ".rb", ".inc", ".pl" )

cgi.assign                 = ( ".pl"  => "/usr/bin/perl",
                       ".cgi" => "/usr/bin/perl",
                       ".rb"  => "/usr/bin/ruby",
                       ".erb" => "/usr/bin/eruby",
                       ".py"  => "/usr/bin/python",
                       ".php" => "/usr/bin/php-cgi" )

index-file.names   += ( "index.pl",   "default.pl",
                       "index.rb",   "default.rb",
                       "index.erb",  "default.erb",
                       "index.py",   "default.py",
                       "index.php",  "default.php" )

server.errorlog    = "/var/log/lighttpd/error.log"
accesslog.filename = "/var/log/lighttpd/access.log"

fastcgi.debug = 1
fastcgi.server = ("/api.fcgi" =>
  ((
     "socket" => "/tmp/api-fcgi.sock",
     "bin-path" => "/var/www/api/api.fcgi",
     "check-local" => "disable",
     "max-procs" => 1
  ))
)

alias.url = ( 
   "/api/" => "/var/www/api"
)

url.rewrite-once = (
  "^(/api($|/.*))$" => "$1",
  "^(/.*)$" => "/api.fcgi$1"
)
There is no error when running "/var/www/api/api.fcgi" under terminal.
I hoped someone could sincerely help me to point the mistake and appreciate to thank.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Paramiko Server -- Exception (server): Error reading SSH protocol banner ujlain 3 4,502 Jul-24-2023, 06:52 AM
Last Post: Gribouillis
  TCP server syntax error wabbit 2 1,507 May-18-2023, 06:40 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020