mirror of
https://github.com/gabehf/cloudcomputing-project.git
synced 2026-03-07 21:48:16 -08:00
simple POST implimentation
This commit is contained in:
parent
366ee3ff5d
commit
61a047f198
2 changed files with 24 additions and 21 deletions
|
|
@ -1 +0,0 @@
|
|||
{"openapi":"3.0.3","info":{"title":"MusicAPI","version":"1.0","x-logo":{"url":""}},"paths":{"/":{"summary":"home page","get":{"tags":[]},"x-last-modified":1667004520934},"/add":{"summary":"add a song to the database","post":{"tags":[]},"x-last-modified":1667004538430},"/search?s={query}":{"get":{"tags":[]},"x-last-modified":1667004563860}},"components":{"securitySchemes":{},"schemas":{"home page":{"type":"string","format":"text/html","x-last-modified":1667004601418},"add response":{"type":"boolean","format":"boolean","x-last-modified":1667004629755},"search response":{"type":"object","required":["Title","Artist","File"],"x-last-modified":1667004679899}},"headers":{},"responses":{},"parameters":{}},"tags":[],"servers":[{"url":"https://api.example.io"}],"security":[]}
|
||||
44
src/index.js
44
src/index.js
|
|
@ -3,21 +3,6 @@ const fs = require('fs')
|
|||
const AWS = require('aws-sdk');
|
||||
const docClient = new AWS.DynamoDB.DocumentClient();
|
||||
|
||||
// let data = {
|
||||
// songs: [
|
||||
// {
|
||||
// Title: "Well Enough",
|
||||
// Artist: "Future Teens",
|
||||
// File: "this.mp3"
|
||||
// },
|
||||
// {
|
||||
// Title: "BYOB",
|
||||
// Artist: "Future Teens",
|
||||
// File: "that.mp3"
|
||||
// },
|
||||
// ]
|
||||
// }
|
||||
|
||||
const params = {
|
||||
TableName: 'MusicTable'
|
||||
}
|
||||
|
|
@ -57,10 +42,14 @@ const template = `
|
|||
<body>
|
||||
<div class="content">
|
||||
<h1>Illegal Music Site</h1>
|
||||
<form>
|
||||
<input type="text" placeholder="Title" />
|
||||
<input type="text" placeholder="Artist" />
|
||||
<input type="File" />
|
||||
<form onSubmit="formSubmit()" name="addForm">
|
||||
<label for="Title">Title</label>
|
||||
<input type="text" id="Title" name="Title" placeholder="Title" />
|
||||
<label for="Artist">Artist</label>
|
||||
<input type="text" id="Artist" name="Artist" placeholder="Artist" />
|
||||
<label for="File">File</label>
|
||||
<input type="File" id="File" name="File"/>
|
||||
<input type="submit"/>
|
||||
</form>
|
||||
<div>
|
||||
{{@each(it.songs) => s, i}}
|
||||
|
|
@ -72,7 +61,22 @@ const template = `
|
|||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
async function formSubmit() {
|
||||
let title = document.getElementById("Title").value
|
||||
let artist = document.getElementById("Artist").value
|
||||
|
||||
let resp = await fetch("/add", {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
Artist: artist,
|
||||
Title: title
|
||||
})
|
||||
})
|
||||
window.location.reload()
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
<style>
|
||||
body {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue