Remove harcoded API host
This commit is contained in:
parent
e13ccf9665
commit
f4268c5b48
|
@ -1,2 +1,2 @@
|
|||
FLASK_SECRET_KEY=your_secret_key
|
||||
DATABASE=sqlite:///endpoints.db
|
||||
DATABASE=sqlite:///endpoints.db
|
||||
API_HOST=windows.local
|
|
@ -5,7 +5,9 @@ from api import api
|
|||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
DATABASE_URI = os.getenv('DATABASE')
|
||||
API_HOST = os.getenv('API_HOST')
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI
|
||||
|
@ -17,7 +19,7 @@ init_db(app)
|
|||
@app.route('/')
|
||||
def homepage():
|
||||
endpoints = get_endpoints_from_db()
|
||||
return render_template('index.html', endpoints=endpoints)
|
||||
return render_template('index.html', endpoints=endpoints, api_host=API_HOST)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=5000)
|
||||
|
|
|
@ -128,19 +128,19 @@
|
|||
<h2>cURL Commands</h2>
|
||||
<pre>
|
||||
# Get all endpoints
|
||||
curl http://windows.local:5000/api/endpoints
|
||||
curl http://{{ api_host }}:5000/api/endpoints
|
||||
|
||||
# Get Endpoint 1
|
||||
curl http://windows.local:5000/api/endpoints/1
|
||||
curl http://{{ api_host }}:5000/api/endpoints/1
|
||||
|
||||
# Get Endpoint 2
|
||||
curl http://windows.local:5000/api/endpoints/2
|
||||
curl http://{{ api_host }}:5000/api/endpoints/2
|
||||
|
||||
# Update Endpoint 1
|
||||
curl -X PUT http://windows.local:5000/api/endpoints/1 -H "Content-Type: application/json" -d '{"url": "http://new.url/for/endpoint1"}'
|
||||
curl -X PUT http://{{ api_host }}:5000/api/endpoints/1 -H "Content-Type: application/json" -d '{"url": "http://new.url/for/endpoint1"}'
|
||||
|
||||
# Update Endpoint 2
|
||||
curl -X PUT http://windows.local:5000/api/endpoints/2 -H "Content-Type: application/json" -d '{"url": "http://new.url/for/endpoint2"}'
|
||||
curl -X PUT http://{{ api_host }}:5000/api/endpoints/2 -H "Content-Type: application/json" -d '{"url": "http://new.url/for/endpoint2"}'
|
||||
</pre>
|
||||
|
||||
<script>
|
||||
|
@ -148,7 +148,7 @@ function updateEndpoint(event, endpointId) {
|
|||
event.preventDefault();
|
||||
const newUrl = document.getElementById(`new-url-${endpointId}`).value;
|
||||
|
||||
fetch(`http://windows.local:5000/api/endpoints/${endpointId}`, {
|
||||
fetch(`http://{{ api_host }}:5000/api/endpoints/${endpointId}`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
|
Loading…
Reference in New Issue