core integration fix 1

This commit is contained in:
Łukasz Jędyk 2022-01-25 14:14:54 +01:00
parent abf43f17ec
commit 498d514708

View File

@ -30,19 +30,19 @@ def get_twitter_campaigns():
def add_twitter_account(): def add_twitter_account():
content_type = request.headers.get('Content-Type') content_type = request.headers.get('Content-Type')
if (content_type == 'application/json'): if (content_type == 'application/json'):
json = request.json request_json = request.json
if not json['campaign_name'] or not json['user_input'] or not json['twitter_account_id']: if not request_json['campaign_name'] or not request_json['user_input'] or not request_json['twitter_account_id']:
return "Invalid request!", 400 return "Invalid request!", 400
else: else:
consumer_key = current_app.config["TWITTER_CONSUMER_KEY"] consumer_key = current_app.config["TWITTER_CONSUMER_KEY"]
consumer_secret = current_app.config["TWITTER_CONSUMER_SECERT"] consumer_secret = current_app.config["TWITTER_CONSUMER_SECERT"]
twitter_account = TwitterAccount.query.filter_by(twitter_account_id=json['twitter_account_id']).first() twitter_account = TwitterAccount.query.filter_by(twitter_account_id=request_json['twitter_account_id']).first()
# generate campaign content # generate campaign content
core_url = 'http://65.108.80.28:4999/generate' core_url = 'http://65.108.80.28:4999/generate'
payload = { payload = {
"data": json['user_input'], "data": request_json['user_input'],
"length": 400 "length": 400
} }
@ -66,9 +66,9 @@ def add_twitter_account():
# save campaign to database # save campaign to database
new_twitter_campaign = TwitterCampaign( new_twitter_campaign = TwitterCampaign(
campaign_name = json['campaign_name'], campaign_name = request_json['campaign_name'],
twitter_account_id = json['twitter_account_id'], twitter_account_id = request_json['twitter_account_id'],
user_input = json['user_input'], user_input = request_json['user_input'],
generated_content = generated_content, generated_content = generated_content,
twitter_post_id = response['id'] twitter_post_id = response['id']
) )