https://github.com/messeb/alleswisser
https://github.com/messeb/alleswisser
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/messeb/alleswisser
- Owner: messeb
- License: mit
- Created: 2018-09-13T17:07:00.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-09-03T17:57:08.000Z (almost 7 years ago)
- Last Synced: 2025-02-18T09:58:55.562Z (over 1 year ago)
- Language: TypeScript
- Size: 31.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Alleswisser
Service to get answers for questions in german. It uses the [WolframAlpha Short Answers API](https://products.wolframalpha.com/short-answers-api/documentation/).
Because the [Short Answers API](https://products.wolframalpha.com/short-answers-api/documentation/) supports only englisch questions, the initial question is translated to english and the answer is translated back to german.
## Prerequisite
[WolframAlpha API](https://products.wolframalpha.com/api/): Create a free account for api access and register an app to get an api app id.
## Deployment
[](https://heroku.com/deploy?template=https://github.com/messeb/alleswisser)
### Heroku
* Install the [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli) and [login](https://devcenter.heroku.com/articles/heroku-cli#getting-started) via the CLI.
* Create a new app via the CLI
```
$ heroku create
```
or select an existing app
```
$ heroku git:remote -a [app name]
```
* Set the [WolframAlpha app id](http://developer.wolframalpha.com/portal/myapps/) as Heroku environment variable
```
$ heroku config:set WOLFRAM_ALPHA_APP_ID=[app id]
```
* Deploy it on Heroku
```
$ git push heroku master
```
### Local
* Export the [WolframAlpha app id](http://developer.wolframalpha.com/portal/myapps/) as environment variable
```
$ export WOLFRAM_ALPHA_APP_ID=[app id]
```
* Install all dependencies
```
$ npm install
```
* Run it for production
```
$ npm start
```
or for development, without separated TypeScript transpiling
```
$ npm run dev
```
## Usage
Send a json structure with the question via post request to your Heroku app.
### Json structure
```
{
"question": "Wie groß ist eine Giraffe?"
}
```
### Sample request
```
curl -X "POST" "https://[Heroku App ID].herokuapp.com/" \
-H 'Content-Type: application/json; charset=utf-8' \
-d $'{
"question": "Wie groß ist eine Giraffe?"
}'
```
### Response
The response contains the question, a field if an answer exists and the answer:
```
{
"question": "Wie groß ist eine Giraffe?",
"has_answer": true,
"answer": "4 bis 6 Meter"
}
```
## Hint
The service is currently not protected via an api key or some other credentials. Because the usage of the WolframAlpha api can cause additional costs, you should have a look at it.