0

I am attempting to deploy a simple Hello World script on XAMMP.

In case the link is removed here is application.py:

from flask import Flask 
app = Flask(__name__)
@app.route("/")
def hello():
    return "Hello World!"

My applciation.cgi script is as follows:

#!C:/Users/Simon/Documents/Python/Scripts/python.exe
from wsgiref.handlers import CGIHandler
from application import hello
CGIHandler().run(app)

C:/Users/Simon/Documents/Python/ is the location of my virtual python environment.

I have configured XAMMP (httpd.conf) in the following way:

AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict

This configuration I kept in all cases.

I tried the following as suggested in the documentation:

ScriptAlias /Network C:/Users/Simon/Documents/Network/application.cgi

This failed and I tried this as suggested in here:

<Directory "C:/Users/Simon/Documents/Network">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Require all granted
</Directory>

Alias /Network "C:/Users/Simon/Documents/Network"

In all cases an Error 500 Server error! was returned.

I'm not sure if it's needed but here is the relevant error showing in access.log:

192.168.0.8 - - [17/Feb/2018:13:21:12 +0000] "GET / HTTP/1.1" 500 1100 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36"

If anything is missing please tell me and I will add it.

How can I correctly configure my server so that I can run this script?


There was mistake in application.cgi:

#!C:/Users/Simon/Documents/Python/Scripts/python.exe
from wsgiref.handlers import CGIHandler
from application import hello
CGIHandler().run(hello)

It is however still returning an error:

A server error occurred. Please contact the administrator.

2
  • have you completed this task? Commented Aug 14, 2020 at 7:29
  • @VaibhavkumarChaudhary Unfortunatly not. I ended up giving up on it. Commented Aug 14, 2020 at 10:54

1 Answer 1

1

You've imported the wrong thing in your CGI script; as a result app is not defined. You should be importing that rather than hello.

Sign up to request clarification or add additional context in comments.

3 Comments

That was a bad mistake. I'm getting another error now: A server error occurred. Please contact the administrator. Do you know what could be causing that?
Now you've changed the wrong thing. You should import app and pass it to run().
Now trying from application import app, CGIHandler().run(app). I'm getting a 404 error (not found error) you could not tell me if I should be using ScriptAlias /Network C:/Users/Simon/Documents/Network/application.cgi or the other listed (or both)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.