Hello,
I've got a pretty simple Flask Api I can hit locally just fine but can't seem to get it configured properly to hit it on pythonanywhere.
Here is the wsgi.py file:
# This file contains the WSGI configuration required to serve up your
# web application at http://<your-username>.pythonanywhere.com/
# It works by setting the variable 'application' to a WSGI handler of some
# description.
#
# The below has been auto-generated for your Flask project
import sys
# add your project directory to the sys.path
project_home = '/home/davidayres/pulse-site'
if project_home not in sys.path:
sys.path = [project_home] + sys.path
# import flask app but need to call it "application" for WSGI to work
from app import app as application # noqa
My Flask api class code (name of file is app.py, which I have uploaded to the files area):
from flask import Flask, request
from flask_restful import Resource, Api
from datetime import datetime, date
import calendar
import csv
app = Flask(__name__)
api = Api(app)
class ProcessActualTimePunches(Resource):
def post(self):
self.time_detail_file = request.files[self.time_detail_file_name].read()
self.pay_rates_file = request.files[self.pay_rates_file_name].read()
self.week_start_index = request.form.get("WeekStartIndex")
self.process_files()
return self.list_time_punches
api.add_resource(ProcessActualTimePunches, '/timedetail')
When I try to access the route at davidayres.pythonanywhere.com/timedetail I get a 404 error.
Do I need to start my flask api somehow, or is it supposed to be running automatically? I've gone through the documentation but didn't see anything specific I should be doing.
Thanks for any assistance.
Kind regards,
David