Navigate to https://www.pythonanywhere.com/
Register:
Click on All Web Apps
Click on the Add new app
Select Flask
At this time you will be prompted for Python version, you likely want a 3.7, but you can validate what version you are running to match your local machine, like so:
Click Next
Your default URL and app will look like this:
Click on the directory right under the source code
Click on the flask_app.py
This is what you should see at this point
Copy-paste some Flask code, there is a snippet below
Remove the app.run(debug = True) on the bottom if it is there
Remove the app.run(debug = True) on the bottom if it is there
You can click Run like in the image above to run the app and see the console
when ready, hit the reload sign and you should now have your new app deployed
when ready, hit the reload sign and you should now have your new app deployed
Placing flask application on pythonanywhere
modify your flask_app.py and add following code:
from flask import Flask, jsonify, request, abort app=Flask(__name__) data=[{'fname':'Steve', 'lname':'Jobbs'},{'fname':'Bill', 'lname':'Gates'}] @app.route('/createperson', methods=['POST']) def create_person(): print(request.json) if not request.json or not 'person' in request.json: abort(400) data.append(request.json['person']) return jsonify({'data' : data}), 201 @app.route('/data', methods=['GET']) def get_data(): return jsonify({'data' : data}) @app.route('/data/', methods=['GET']) def get_data_byid(id): return jsonify({'data' : data[id]})